Polycarp has $$$26$$$ tasks. Each task is designated by a capital letter of the Latin alphabet.The teacher asked Polycarp to solve tasks in the following way: if Polycarp began to solve some task, then he must solve it to the end, without being distracted by another task. After switching to another task, Polycarp cannot return to the previous task.Polycarp can only solve one task during the day. Every day he wrote down what task he solved. Now the teacher wants to know if Polycarp followed his advice.For example, if Polycarp solved tasks in the following order: "DDBBCCCBBEZ", then the teacher will see that on the third day Polycarp began to solve the task 'B', then on the fifth day he got distracted and began to solve the task 'C', on the eighth day Polycarp returned to the task 'B'. Other examples of when the teacher is suspicious: "BAB", "AABBCCDDEEBZZ" and "AAAAZAAAAA".If Polycarp solved the tasks as follows: "FFGZZZY", then the teacher cannot have any suspicions. Please note that Polycarp is not obligated to solve all tasks. Other examples of when the teacher doesn't have any suspicious: "BA", "AFFFCC" and "YYYYY".Help Polycarp find out if his teacher might be suspicious.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$). Then $$$t$$$ test cases follow. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of days during which Polycarp solved tasks. The second line contains a string of length $$$n$$$, consisting of uppercase Latin letters, which is the order in which Polycarp solved the tasks.

For each test case output:    "YES", if the teacher cannot be suspicious;  "NO", otherwise.  You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).

5
3
ABA
11
DDBBCCCBBEZ
7
FFGZZZY
1
Z
2
AB

"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', input => inputString += input);
process.stdin.on('end', () => {
    inputString = inputString.trim().split('\n').map(string => string.trim());
    main();
});

function print(message) {
    console.log(message);
}

function readLine() {
    return inputString[currentLine++];
}

function readLineNumber(parse = parseInt) {
    return parse(readLine());
}

function main() {
    // 1 <= t <= 1000
    const tests = readLineNumber();

    for (let t = 0; t < tests; t++) {
        // 1 <= n <= 50
        const days = readLineNumber();
        const string = readLine();
        const questions = {};
        let isRight = true;

        for (let d = 0; d < days; d++) {
            let letter = string[d];

            if(questions.hasOwnProperty(letter)) {
                if(d - questions[letter] > 1) {
                    print("NO");
                    isRight = false;
                    break;
                }
                questions[letter] = d;
            } else {
                questions[letter] = d;
            }
        }

        if(isRight) {
            print("YES");
        }
    }
}

"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', input => inputString += input);
process.stdin.on('end', () => {
    inputString = inputString.trim().split('\n').map(string => string.trim());
    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
    const quantidadeTestes = parseInt(readline());

    for (let i = 0; i < quantidadeTestes; i++) {
        const tamanhoString = parseInt(readline());
        const string = readline();
        const questoes = {};
        let fezCerto = true;

        for (let l = 0; l < tamanhoString; l++) {
            let letra = string[l];

            if(questoes.hasOwnProperty(letra)) {
                if(l - questoes[letra] > 1) {
                    console.log("NO");
                    fezCerto = false;
                    break;
                }
                questoes[letra] = l;
            } else {
                questoes[letra] = l;
            }
        }

        if(fezCerto) {
            console.log("YES");
        }
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
	inputString += inputStdin;
});

process.stdin.on('end', _ => {
	inputString = inputString.trim().split('\n').map(string => {
		return string.trim();
	});

	main();
});

function readline() {
	return inputString[currentLine++];
}

function main() {
	var t = readline();
	let count = 1;
	while (count <= t) {
		let n = readline()
		var stringArray = Array.from(readline());
		var b = stringArray.filter(function (item, pos, arr) {
			return pos === 0 || item !== arr[pos - 1];
		});
		const hasDuplicates = arr => arr.some((item, index) => arr.indexOf(item) !== index)
		if (hasDuplicates(b)) {
			console.log("NO")
		}
		else {
			console.log("YES")

		}
		// console.log(results)

		count++
	}
}

/**
 * Author : Fazlul Hoque
 * Node.js version : 12.16.3
 * command : node fileName.js <input.txt >output.txt
 */
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = ""; //An array of  raw inputs (includes 'n,\r , not usable. need to process before use)
let currentLine = 0; //input sequence controller variable.

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main(); // after input
});

/********** Utility Functions Start **********/
/**
 *  read row Input
 * @returns string
 */
function _readRawLine() {
    return inputString[currentLine++];
}
function readLine(){
    // return _readRawLine().replace(/\s+$/g, '');
    return _readRawLine().replace('\r', '');
}

function print(x) {
    console.log(x);
}

function readSingleInt() {
    const p = readLine();
    return parseInt(p);
}

function readIntArray() {
    return readLine().split(" ").map((v) => parseInt(v));
}

function readArray() {
    return readLine().split(" ");
}

function int(n) {
    return parseInt(n);
}
/********** Utility Functions End **********/
/**
 * Don't Touch this fucntion at all , unless you know what are you doing!
 */
function main() {
    solve();
}

// ********** actual Code Starts from here **********

function prcessString(st=""){
    const objMap = {};
    let lastChar = st[0];
    objMap[st[0]]=true;
    for(let i=0;i<st.length;i++){
        if(lastChar==st[i]){
            lastChar = st[i];
        }else{
            if(objMap[st[i]]){
                return false;
            }
            lastChar = st[i];
            objMap[st[i]] =true;
        }
    }
    return true;
}

function solve() {
    let n = readSingleInt();
    let p,st;
    while(n--){
         p = readSingleInt();
         st = readLine();
        console.log(prcessString(st) ? "YES" : "NO");
    }
}

/**
 * Author : Fazlul Hoque
 * Node.js version : 12.16.3
 * command : node fileName.js <input.txt >output.txt
 */
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = ""; //An array of  raw inputs (includes 'n,\r , not usable. need to process before use)
let currentLine = 0; //input sequence controller variable.

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main(); // after input
});

/********** Utility Functions Start **********/
/**
 *  read row Input
 * @returns string
 */
function _readRawLine() {
    return inputString[currentLine++];
}
function readLine(){
    // return _readRawLine().replace(/\s+$/g, '');
    return _readRawLine().replace('\r', '');
}

function print(x) {
    console.log(x);
}

function readSingleInt() {
    const p = readLine();
    return parseInt(p);
}

function readIntArray() {
    return readLine().split(" ").map((v) => parseInt(v));
}

function readArray() {
    return readLine().split(" ");
}

function int(n) {
    return parseInt(n);
}
/********** Utility Functions End **********/
/**
 * Don't Touch this fucntion at all , unless you know what are you doing!
 */
function main() {
    solve();
}

// ********** actual Code Starts from here **********

function prcessString(st=""){
    const objMap = {};
    let lastChar = st[0];
    for(let i=0;i<st.length;i++){
        if(lastChar==st[i]){
            objMap[st[i]] = true;
            lastChar = st[i];
        }else{
            if(objMap[st[i]]){
                return false;
            }
            lastChar = st[i];
            objMap[st[i]] =true;
        }
    }
    return true;
}

function solve() {
    let n = readSingleInt();
    let p,st;
    while(n--){
         p = readSingleInt();
         st = readLine();
        console.log(prcessString(st) ? "YES" : "NO");
    }
}

/**
 * Bismillahir Rahmanir Rahim
 * This code has been taken from: https://codeforces.com/blog/entry/69610
 */
 process.stdin.resume();
 process.stdin.setEncoding('utf-8');

 let inputString = '';
 let currentLine = 0;

 process.stdin.on('data', inputStdin => {
     inputString += inputStdin;
 });

 process.stdin.on('end', _ => {
     inputString = inputString.trim().split('\n').map(string => {
         return string.trim();
     });

     main();
 });

 function readLine() {
     return inputString[currentLine++];
 }

 /****** BELOW HERE START WRITING YOUR CODE IN main() FUNCTION   ***************************************/
 /**
  * Use "readLine()" function for input, which will return a string consisting the entire line, so accordingly split the string
  * when required.
  *
  * I am using console.log() to output
  */
//  function main() {
//      let t = readLine();
//      t = parseInt(t);
//      console.log("mai yahan aaya")
//      while(t--) {
//          let line = readLine();
//          line = line.split(" ");
//          let n = parseInt(line[0]);
//          let m = parseInt(line[1]);
//          if(n === 1) {
//              console.log("0");
//          } else if (n === 2) {
//              console.log(m);
//          } else {
//              console.log(2*m);
//          }
//      }
//  }

function main() {

	let t = parseInt(readLine());
	// t = parseInt(t);
	while(t--) {
		let n = readLine();
		n = parseInt(n);
		let s = readLine();
		// console.log(n,s);
		if (!solve(n, s)) console.log("NO");
		else console.log("YES");
	}
    // console.log(t);
}

function solve(n, s) {
	let flag = true;
	let visited = new Set();
	for (let i = 0; i < n; i++) {
		if(visited.has(s[i]) && s[i] !== s[i-1]) {
			flag = false;
			break;
		} else {
			visited.add(s[i]);
		}
	}
	return flag;
}

/**
 * Bismillahir Rahmanir Rahim
 * This code has been taken from: https://codeforces.com/blog/entry/69610
 */
 process.stdin.resume();
 process.stdin.setEncoding('utf-8');

 let inputString = '';
 let currentLine = 0;

 process.stdin.on('data', inputStdin => {
     inputString += inputStdin;
 });

 process.stdin.on('end', _ => {
     inputString = inputString.trim().split('\n').map(string => {
         return string.trim();
     });

     main();
 });

 function readLine() {
     return inputString[currentLine++];
 }

 /****** BELOW HERE START WRITING YOUR CODE IN main() FUNCTION   ***************************************/
 /**
  * Use "readLine()" function for input, which will return a string consisting the entire line, so accordingly split the string
  * when required.
  *
  * I am using console.log() to output
  */
//  function main() {
//      let t = readLine();
//      t = parseInt(t);
//      console.log("mai yahan aaya")
//      while(t--) {
//          let line = readLine();
//          line = line.split(" ");
//          let n = parseInt(line[0]);
//          let m = parseInt(line[1]);
//          if(n === 1) {
//              console.log("0");
//          } else if (n === 2) {
//              console.log(m);
//          } else {
//              console.log(2*m);
//          }
//      }
//  }

function main() {

	let t = parseInt(readLine());
	// t = parseInt(t);
	while(t--) {
		let n = readLine();
		n = parseInt(n);
		let s = readLine();
		// console.log(n,s);
		if (!solve(n, s)) console.log("NO");
		else console.log("YES");
	}
    // console.log(t);
}

function solve(n, s) {
	let table = {};
	for (let i = 0; i < 26; i++) {
		table[String.fromCharCode(65+i)] = false;
	}
	let flag = true;
	for (let i = 0; i < n; i++) {
		if (!i) {
			table[s[i]] = true;
			continue;
		}
		if(s[i]==s[i-1] && table[s[i]]) {
			continue;
		} else if(s[i]!=s[i-1] && !table[s[i]]) {
			table[s[i]] = true;
		} else if(s[i]!=s[i-1] && table[s[i]]) {
			flag = false;
			break;
		}
	}
	return flag;
}

let input = '';
process.stdin.on('data', (c) => {
    input += c;
});

process.stdin.on('end', () => {
    const lines = input.split('\n');
    const cases = parseInt(lines[0]);

    let prevLetter;
    let on = true;
    for (let i = 1; i < cases * 2 + 5; i++) {
        const line = lines[i];
        if (!line) return;
        if (!on) {
            const allChars = [...line].map(t => t.trim());
            const found = [];

            const duplicate = allChars.find((char, index) => {
                if (!found.includes(char)) {
                    found.push(char);
                } else if (allChars[index - 1] !== char) {
                    return true;
                }
            });

            console.log(duplicate ? 'NO' : 'YES');
        }

        on = !on;
    }
});

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

// cat input.txt | node script.js > output.txt
// Number.parseInt(string)
function main() {
    let t = Number.parseInt(readline()), n, s, d, alphabet, suspicious;
    while(t--) {
        n = Number.parseInt(readline());
        s = readline();
        d = s.substr(0, 1);
        for(let i = 1; i < n; ++i) {
            if(s.substr(i, 1) !== s.substr(i - 1, 1)) d += s.substr(i, 1);
        }
        alphabet = {};
        suspicious = false;
        for(let i = 0; i < d.length; ++i) {
            if(alphabet.hasOwnProperty(d[i])) {
                suspicious = true;
            } else {
                alphabet[d[i]] = true;
            }
        }
        suspicious ? console.log('NO') : console.log('YES');
    }
}

const solve = (letter) => {
    const tasks = letter.split('');
    const visited = new Set();
    let last_visited_work = '';

    for (let i = 0; i < tasks.length; i += 1) {
        if (tasks[i] !== last_visited_work) {
            if (visited.has(tasks[i])) {
                return 'NO';
            } else {
                last_visited_work = tasks[i];
                visited.add(tasks[i]);
            }
        }
    }
    return 'YES';
};

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
    const lines = input.trim().split('\n').slice(1)
        .map(l => l.trim());

    for (let i=1; i<lines.length; i+=2) {
        console.log(solve(lines[i]))
    }
})

const solve = (letter) => {
    const tasks = letter.split('');
    const visited = new Set();
    let flag = true;

    for (let i = 0; i < tasks.length; i += 1) {
        if (visited.has(tasks[i]) && tasks[i - 1] !== tasks[i]) {
            flag = false;
            break;
        }
        visited.add(tasks[i]);
    }
    return flag ? 'YES' : 'NO';
};

let input = '';
process.stdin.on('data', (str) => input += str);
process.stdin.on('end', () => {
    const lines = input.trim().split('\n').slice(1)
        .map((l) => l.trim());

    for (let i = 1; i < lines.length; i += 2) {
        console.log(solve(lines[i]));
    }
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
let initialized=false,
    cache = [];

function fairWork(inp){
  cache.push(inp);

  if(cache.length === 2){

    for(let i=0, repeats={}; i<inp.length; i++){
      if( repeats[inp[i]] ){ cache = []; return console.log('NO') }
      if(inp[i] != inp[i+1]){ repeats[inp[i]] = true }
    }

    cache = [];
    return console.log('YES')
  }

}

rl.on('line', (input) => {
  if(initialized){ fairWork(input) }
  else initialized = true
});

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

        let testCases = parseInt(readLine());
        while(testCases--)
        {
            const n = parseInt(readLine());
            const s = readLine();
            a(n,s);
        }

});

function print(c){
    return console.log(c);
}

function get_ints() {
    return readLine().split(' ').map(Number)
}

function readLine() {
        return data[currentLine++];
}

function a(n,s)
{
    let last = '';
        let solved = '';
        for(let i = 0 ; i < n; i++)
        {
            if(s[i] !== last && solved.includes(s[i]))
            {
                return console.log('NO');
            }
            solved += s[i];
            last = s[i];
        }
        return print('YES');
}

module.exports = a;

process.stdin.resume();
process.stdin.setEncoding("utf-8");

var currentLine = 0;
var inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function input() {
  return inputString[currentLine++];
}

/******** Main function *************/

function main() {
  const t = +input();

  for (var m = 0; m < t; m++) {
    var n = +input();
    var str = input().split("");
    var newStr = [];

    // var j = 0;
    for (var i = 0; i <= str.length - 1; i++) {
      if (str[i] != str[i + 1]) {
        newStr.push(str[i]);
      }
    }

    var isNo = false;

    for (var j = 0; j < newStr.length; j++) {
      for (var k = j + 1; k < newStr.length; k++) {
        if (newStr[j] == newStr[k]) {
          console.log("NO");
          isNo = true;
          break;
        }
        if (isNo) {
          break;
        }
      }
    }
    if (!isNo) {
      console.log("YES");
    }
    // console.log(newStr);
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");

var currentLine = 0;
var inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function input() {
  return inputString[currentLine++];
}

/******** Main function *************/

function main() {
  const t = +input();

  for (var m = 0; m < t; m++) {
    var n = +input();
    var str = input().split("");
    var newStr = [];

    var j = 0;
    for (var i = 0; i <= str.length - 1; i++) {
      if (str[i] != str[i + 1]) {
        newStr.push(str[i]);
      }
    }

    var isNo = false;

    for (var j = 0; j < newStr.length; j++) {
      for (var k = j + 1; k < newStr.length; k++) {
        if (newStr[j] == newStr[k]) {
          console.log("NO");
          isNo = true;
          break;
        }
        if (isNo) {
          break;
        }
      }
    }
    if (!isNo) {
      console.log("YES");
    }
    // console.log(newStr);
  }
}

const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});

let c = 0;

rl.on("line", (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c % 2 !== 0) {
    c++;
    return;
  }

  const letters = d.split("");
  const prevLetters = {};
  prevLetters[letters[0]] = true;
  let ans = "YES";
  let prev = letters[0];
  for (let i = 1; i < letters.length; i++) {
    if (prev !== letters[i] && prevLetters.hasOwnProperty(letters[i])) {
      ans = "NO";
      break;
    }

    prev = letters[i];
    prevLetters[letters[i]] = true;
  }

  console.log(ans);

  c++;
});

rl.on("close", () => {});

// Common Template Starts //
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = ""
let currentLine = 0

process.stdin.on("data", inputStdin => inputString += inputStdin)

process.stdin.on("end", (_) => {
    inputString = inputString.trim().split("\n").map((string) => string.trim())
    main()
})

const readline = () => inputString[currentLine++]
// Common Template Ends //

// Driver Function Starts //
const main = () => {
    console.clear()

    let n   = 0
    let arr = []
    let str = ''

    // let nums = generateUptoNwithoutK(1000, 3)

    // with testcases
    //*
    let t = parseInt( readline() )
    while (t--) {
        n   = parseInt( readline() )
        // arr = readline().split(' ').map(Number)
        str = readline()
        console.log( solve(n, arr, str) )
    }
    //*/

    // without testcases
    /*
        n   = parseInt( readline() )
        arr = readline().split(' ').map(Number)
        // str = readline()
        console.log( solve(n, arr, str) )
    //*/
}
// Driver Function Ends //

// MAIN LOGIC
const solve = (n, arr, str) => {

    let task = []
    let uniq = findUnique( str ).split('')

    for( let u of uniq ) {
        task[u] = findAllIndicesOfChar(str, u)
    }

    for( let t in task ) {
        let diff = 0
        let i = 0
        while( i < task[t].length - 1 ) {
            diff = Math.abs( task[t][i] - task[t][i+1] )
            if( diff > 1 ) return 'NO'
            i++
        }
    }

    return 'YES'
}

const generateUptoNwithoutK = (n, k) => {
    let a = [], i = 1
    while( a.length <= n ){
        // if( i%k != 0 && !stringHasCharacter(i.toString(), k ) ) a.push( i )
        if( i%k != 0 && i%10 != k ) a.push( i )
        i++
    }
    return a
}

const isOdd         = (num) => num & 1
const isEven        = (num) => !(num & 1)
const minOfArray    = (arr) => Math.min.apply(null, arr)
const maxOfArray    = (arr) => Math.max.apply(null, arr)
const uniqueArray   = (arr) => [...new Set(arr)]
const sortArray     = (arr) => arr.sort((a, b) => a - b)
const sortArrayDesc = (arr) => arr.sort( (a, b) =>  b - a )
const isSorted      = (arr) => arr.every((v, i, a) => !i || a[i - 1] <= v)
const sumOfArray    = (arr) => arr.reduce((partialSum, a) => partialSum + a, 0)
const splitAt       = index => x => [x.slice(0, index), x.slice(index)]
const elemFrequency = (arr) => arr.reduce( (acc, curr) => { return acc[curr] ? ++acc[curr] : acc[curr] = 1, acc }, {})
const deepCopyArray = (arr) => arr.map(a => ({...a}))

const reverseText            = (str)        =>  str.split('').reverse().join('')
const stringHasDuplicates    = (str)        => (/([a-z])\1/i).test(str)
const stringHasDuplicateChar = (str, char)  => str.indexOf(char) !== str.lastIndexOf(char)
const stringHasCharacter     = (str, char)  => str.indexOf(char) > -1 ? true : false

const findAllIndicesOfChar = (str, char) => {
    str = str.split('')
    let indices = [];
    for (let i = 0; i < str.length; i++) {
        if (str[i] === char) indices.push(i);
    }
    return indices
}

const isUpper       = str => !/[a-z]/.test(str) && /[A-Z]/.test(str)
const escapeRegExp  = (string) => string.replace(/[.*+\-?^$$${}()|[\]\\]/g, '\\$$$&')
const replaceAll    = (str, find, replace) => str.replace(new RegExp(escapeRegExp(find), 'g'), replace)

const findUnique = (str) => {
    return [...str].reduce((acc, curr) => {
        return acc.includes(curr) ? acc : acc + curr;
    }, "")
}

const unique = (str) => {
    const cleanStr = str.replace(/ /gi, '');
    const set = [...new Set(cleanStr)];
    return set;
}

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const s = rl();

		const seen = new Set([s[0]]);
		let ok = true;
		for (let i = 1; ok && i < n; i++) {
			if (s[i] != s[i-1]) {
				ok = !seen.has(s[i]);
				seen.add(s[i]);
			}
		}

		console.log(ok ? 'YES' : 'NO');
	}
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var n = lines[0];
    var m = '';
    var l = '';
    for(var j = 1; j < (Number(n) + 1) * 2; j++){
        var sus = false;
        if(j % 2 == 1){
            m = Number(lines[j]);
        }else if(j % 2 === 0){
                var lastSeen =new Map();

            l = lines[j].split('');
            for(var b = 0; b < m; b++){
                let current = l[b];
                let last = lastSeen[current];

                if(last === undefined || last == b -1){
                }else {
                    sus = true;
                    break;
                }
               // console.log(current, last, lastSeen, sus)

                lastSeen[current] = b;
            }
            if(sus === true){
                console.log('NO');
            }else{
                console.log('YES');
            }
        }
    }
});

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', function (inputStdin) {
    inputString += inputStdin;
});

process.stdin.on('end', function () {
    inputString = inputString.split('\n');
    main();
});

function readLine() {
    return inputString[currentLine++];
}

function problemSolving(n, str) {
    var flag = false;
    for (let j = 0; j < str.length; j++) {
        for (let o = j; o < str.length - 1; o++) {

            if (str[o] != str[j] && str[o + 1] == str[j]) {
                flag = true;
                break;
            }
        }
    }
    if (flag)
        console.log("NO");
    else
        console.log("YES");
}

function main() {

    let t = parseInt(readLine().trim(), 10);
    while (t-- > 0) {
        const n = parseInt(readLine().trim(), 10);
        const str = readLine();
        problemSolving(n, str);
    }
}

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	let t = nl.num();
    let ans = [];
    for(let i = 0; i < t; i++){
		nl.num();
		let s = nl.line();
		let p = '';
		let m = [];
		s.split('').forEach((e) => {
			if (e != p) {
				m.push(e);
			}
			p = e;
		});
		m.sort();
		p = '';
		let flag = true;
		m.forEach((e) => {
			if (e === p) {
				flag = false;
			}
			p = e;
		});

        ans.push(flag);
    }

	console.log(ans.map(e => e?'YES':'NO').join("\n"));

};

process.stdin.on('end', sol);

input()
//-------------------

function input () {
  let i = ''
  process.stdin.on('data', c => i += c)
  process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    //console.log(lines);
    solve(lines)
  })

}

function solve (arr) {
  var d =+arr[0]

  for (var i =1 ;i <=d ;i++){
    var str =arr[2*i]

    console.log(test(str))

  }

}

function test(str){
  var mas =["_"]

  for (var c of str){
    if (c == mas[mas.length-1]) continue;

    if (mas.includes(c)){
      return "NO"
    }else {
      mas.push (c)
    }

  }
  return "YES"

}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
   const test= readline();
   let a;
   for(let i=0;i<test;i++){
       let day=readline();
       let str=readline();
       console.log(solve(str));

   }

   }
   function solve(str){
       const set = new Set();
       let flag = true;
       for(let i=0;i<str.length;i++){
           if (set.has(str[i]) && str[i-1] !== str[i]) {
			flag = false;
			break;
		}

		set.add(str[i]);
       }
       return flag ? 'YES' : 'NO';
   }

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
let input = [];
rl.on('line', line => {
    input.push(line);
})
rl.on('close', line => {
    var t = Number(input[0]);
    var b = 1;
    for (var a = 0; a < t; a++) {
        var n = Number(input[b]);
        b++;
        var str = input[b];
        str += " ";
        b++;
        var set = new Set();
        var i;
        for (i = 1; i < str.length; i++) {
            if (str[i] !== str[i - 1]) {
                set.add(str[i - 1]);
            }
            if (set.has(str[i])) {
                console.log("NO");
                break;
            }
        }
        if (i === str.length) {
            console.log("YES");
        }
    }
})

const readline = require('readline');
const rl = readline.createInterface({
    input : process.stdin,
    output : process.stdout
});
let data = [];
let dataIdx = 0;

rl.on('line',function(line){//input,
    data.push(...line.trim().split(' '));
}).on('close',function(){//output
    main();
    process.exit();
})

function input(){
    return data[dataIdx++];
}

//////////////////////////////////////////////////////////

function main(){
    let t = Number(input());
    while(t-->0){
        let ma = Object();
        let n = Number(input());
        let s = input();
        let ans = true;
        for(let i=0;i<n;i++){
            if(ma[s[i]]!=undefined){
                ans = false;
                break;
            }
            if(i!=n-1){
                if(s[i]!=s[i+1]){
                    ma[s[i]] = 1;
                }
            }
        }
        if(ans===true){
            console.log("YES");
        } else {
            console.log("NO");
        }
    }
}

//////////////////////  Nodejs  Problem Solving /////////////////
/////////////////////* @author  Nawab Khairuzzaman Mohammad Kibria *////////

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let currentLine = 0;
let inputString = "";
process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function readLine() {
  return inputString[currentLine++];
}

///////////////////////// END BASIC IO STREAM TEMPLATE //////////////////////

function main() {
  let t = readLine(Number);
  while (t--) {
    let n = readLine(Number);
    let str = readLine().split("");
    const alphaMap = {};
    let result = true;
    for (let i = 0; i < n; i++) {
      if (alphaMap[str[i]] || alphaMap[str[i]] == 0) {
        if (str[i - 1] != str[i]) {
          result = false;
          break;
        } else {
          alphaMap[str[i]] = i;
        }
      } else {
        alphaMap[str[i]] = i;
      }
    }
    if (result) {
      console.log("YES");
    } else {
      console.log("NO");
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function solve()
{
    let num_of_elements = readline();
    let elements = readline();
    let seen_map = new Map();
    let ch_change =false;
    seen_map.set(elements[0],1)
    for(let i=1;i<num_of_elements;i++)
    {

        if(elements[i] != elements[i-1])
        {
            ch_change = true;
        }
        else
            ch_change = false;
        if(seen_map.has(elements[i]) && ch_change)
        {
            console.log("NO")
            return "NO";
        }
        else if(seen_map.has(elements[i]))
        {
            seen_map.set(elements[i],seen_map.get(elements[i]+1));
        }
        else
            seen_map.set(elements[i],1);
    }
    console.log("YES")
    return "YES";
}
function main() {
    let t = readline();
    while(t--)
    {
        solve();

    }

}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    }
)

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    const solved = new Array(500).fill(0)
    solved[arr[0].charCodeAt(0)] = 1
    for (let i = 1; i < n; i++) {
        if (solved[arr[i].charCodeAt(0)] !== 0) {
            if (arr[i] === arr[i - 1]) solved[arr[i].charCodeAt(0)] = 1
            else {
                console.log('NO')
                return
            }
        } else solved[arr[i].charCodeAt(0)] = 1

    }
    console.log('YES')
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) solve(inputArr[i], inputArr[i + 1])
}

function solve(S, N) {
    const hash = {};
    for (let i = 0; i < N; i++) {
        const ch = S[i];
        if (hash[ch] === undefined) {
            hash[ch] = ch;
            continue;
        } else {
            if (S[i - 1] != S[i]) {
                return false;
            }
            hash[ch] = ch;
        }
    }
    return true;
}

function processData(input) {
    //Enter your code here
    input = input.split('\n');
    const T = Number(input[0].trim());
    let i = 1;
    for (let t = 0; t < T; t++) {
        const N = Number(input[i++].trim());
        const S = input[i++].trim();
        const ans = solve(S, N);
        console.log(ans ? 'YES' : 'NO');
    }
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
    processData(_input);
});

const solve = (line) => {
	const tasks = line.split('');

	const set = new Set();
	let flag = true;
	for (let i=0; i<tasks.length; i++) {
		if (set.has(tasks[i]) && tasks[i-1] !== tasks[i]) {
			flag = false;
			break;
		}

		set.add(tasks[i]);
	}

	return flag ? 'YES' : 'NO';
}

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const lines = input.trim().split('\n').slice(1)
		.map(l => l.trim());

	for (let i=1; i<lines.length; i+=2) {
		console.log(solve(lines[i]))
	}
})

let inputString = '';
let currentLine = 0;
process.stdin.on('data', (data) => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map((str) => str.trim());
	main();
});
function readLine() {
	return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
	for (var a = arguments, r = a[0], i = a.length; --i; )
		r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
	return r;
}
function inv(b) {
	for (var a = MOD, u = 0, v = 1, t; b; v = t)
		(t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
	u %= MOD;
	return u < 0 ? u + MOD : u;
}
function pow(base, n) {
	if (n === 0) return 1;
	let p = pow(base, Math.floor(n / 2));
	let res = mul(mod(p), mod(p));
	if (n % 2 === 1) res = mul(mod(res), base);
	return res;
}
function highestOneBit(i) {
	i |= i >> 1;
	i |= i >> 2;
	i |= i >> 4;
	i |= i >> 8;
	i |= i >> 16;
	return i - (i >>> 1);
}
function permutation(arr, len, store = '', permutations = []) {
	if (store.length === len) {
		permutations.push(store);
		return;
	}
	for (let i = 0; i < arr.length; i++) {
		const newArr = [...arr];
		const newChar = newArr.splice(i, 1);
		permutation(newArr, len, store.concat(newChar), permutations);
	}
	return permutations;
}

function main() {
	let t = +readLine();
	while (t--) {
		const len = +readLine();
		let flag = true;
		const str = readLine();
		const visited = new Set();
		const stack = [];
		for (let char of str) {
			const stackTop = stack[stack.length - 1];
			if (stackTop !== char) {
				stack.push(char);
				if (visited.has(char)) {
					flag = false;
					break;
				}
				visited.add(char);
			}
		}
		if (!flag) console.log('NO');
		else console.log('YES');
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
5
3
ABA
11
DDBBCCCBBEZ
7
FFGZZZY
1
Z
2
AB

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = readline();
    let a = readline().split("");

    let map = {
        [a[0]] : true
    };

    for(let i=1;i<a.length;i++) {
        if(a[i] !== a[i-1] && map[a[i]]) {
            console.log('No');
            return;
        } else {
            map[a[i]] = true;
        }
    }

    console.log('Yes');

}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------

function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var s = next();
		var set = new Set();
		var isOK = true;
		for(var j = 0; j < N; j++){
			if(!set.has(s[j])){
				set.add(s[j]);
			}else if(s[j - 1] != s[j]){
				isOK = false;
			}
		}
		myout((isOK) ? "Yes" : "No");
	}
}

var testCases = readline();
for(var j = 0 ; j < testCases ; j++) {
    var output = "YES";
    var length = readline();
    var str = readline();
    var checkObj = {};
    checkObj[str[0]] = true;
    for (var i = 1; i < length; i++) {
        if(str[i] !== str[i-1]){
            if(!checkObj[str[i]]){
                checkObj[str[i]] = true;
            }
            else{
                output = "NO"
            }
        }
    }
    print(output);
}

function main(){
    var t = Number(readline());
    while(t-->0){
        var ma = Object();
        var n = Number(readline());
        var s = readline();
        var ans = true;
        for(var i=0;i<n;i++){
            if(ma[s[i]]!=undefined){
                ans = false;
                break;
            }
            if(i!=n-1){
                if(s[i]!=s[i+1]){
                    ma[s[i]] = 1;
                }
            }
        }
        if(ans===true){
            print("YES");
        } else {
            print("NO");
        }
    }
}
main();

var q = Number(readline());

while (q--) {
    var n = Number(readline());
    var s = readline();
    var mapa={};
    mapa[s[0]]=true;
    var ans=false;
    for(var i=1;i<n;++i){
        if(mapa[s[i]]&&s[i]!==s[i-1]){
            print("NO\n");
            ans=true;
            break;
        }
        mapa[s[i]]=true;
    }
    if (!ans)
        print("YES\n");
}

test = readline();

while (test--) {
    size = readline();
    tasks = readline();
    task = [tasks[0]];
    currentTask = tasks[0];
    flag = true
    for (var i = 1; i < size; i++) {
        if (currentTask === tasks[i]) {
            if(!task.includes(tasks[i])) {
                task.push(tasks[i])
            }
        } else {
            if(task.includes(tasks[i])) {
                flag = false
                break;
            }
            currentTask = tasks[i];
            task.push(currentTask)
        }
    }
    print(flag ? "YES" : "NO")
}

var n = readline();
while(n--) {
    var len = readline();
    var str = readline();
    var store = [];
    var chck = 1;
    for(var i=0; i<len; i++){
        var condition = i==len-1 ? true : str[i+1] && str[i] != str[i+1]
        if(condition) {
            if(store.includes(str[i])) {
                chck = 0
                print("NO");
                break;
            }
            else {
                store.push(str[i])
            }
        }
    }
    if(chck) {
        print("YES")
    }

}

var t = +readline();

while (t--) {
    var n = +readline(); // number of days
    var tasks = readline();
    var taskSet = new Set();
    var answer = "YES";

    for(var i = 0; i < n; i++) {
        while (i + 1 < n && tasks[i + 1] == tasks[i]) {
            i++;
        }
        if(!taskSet.has(tasks[i])) {
            taskSet.add(tasks[i]);
        } else {
            answer = "NO";
            break;
        }
    }
    // print(Array.from(taskSet));
    print(answer);
}

var numberOfCases = Number(readline());
for (var i = 0; i < numberOfCases; ++i) {
    processCase();
}

function processCase() {
    var numberOfDays = Number(readline());
    var record = readline();
    if (!record.length) {
        return print("NO");
    }

    var solvedTasks = new Set();
    var currentTask = record[0];
    for (var char of record) {
        if (char !== currentTask) {
            if (solvedTasks.has(char)) {
                return print("NO");
            }

            solvedTasks.add(currentTask);
            currentTask = char;
        }
    }

    print("YES");
}

const U = 26;
const A = "A".charCodeAt(0);
var T = parseInt(readline());
while (T--) {
	var m = 0;
    var n = parseInt(readline());
    var s = readline();
    var u = s.charCodeAt(0);
    var count = new Array(U);
    for (var i = 0; i < U; ++i)
    	count[i] = 0;
	for (var i = 1; i < n && m < 2; ++i) {
	    var v = s.charCodeAt(i);
		if (v != u)
			m = Math.max(m,++count[u-A]);
		u = v; }
	m = Math.max(m,++count[u-A]);
    print(m == 1 ? "YES": "NO"); }

var t = readline();
    for(var i = 0 ; i < t ; i++){
     var n = readline(),
         a= readline().split('') , counter = 0;
         arrayItems = [...new Set(a)];
         for(var j = 0 ; j < n ; j++){
             if(a[j] != a[j+1]){
                 counter++;
             }
         }
         if(counter == arrayItems.length ){
             print('YES');
         }
         else{
             print("NO");
         }
    }

var tests=+readline(),flag
for(var i=0;i<tests;i++){
    flag=false
    var length=+readline()
    var sequence=readline().split("")
    var test=[]
    for(var j=0;j<length;j++){
        if(sequence[j]===sequence[j+1]){
            continue
        }
        if(test.join("").includes(sequence[j])){
            flag=true
            break
        }
        test.push(sequence[j])
    }
    if(flag){
        print("NO")
    }else{
        print("YES")
    }
}

// 1520 A - Do Not Be Distracted!

// number of test case
var numTests = parseInt( readline() );

for (var numTest = 0; numTest < numTests; numTest++) {

    // input data
    var daysMax = parseInt( readline() );
    var programStudy = readline();

    // variable for loop
    var i = 1;
    var loop = true;

    // check is recognized as positive answer program
    while ( loop && i < programStudy.length + 1 ){

        var str = programStudy.substring(0,i);
        // print('i:'+i+', str:'+str)

        // lettera precedente !=                and   str[ 1,2,3, ..., n-i, ]
        if( programStudy[i] != programStudy[i-1] &&  str.includes(programStudy[i])){
            loop = false;
        }

        i++
    }

    // output program
    if( loop ){
        print('YES');
    } else {
        print('NO');
    }
}

b = readline();
for (j = 0; j < b; j++) {
  z = readline();
  x = readline().split("");
  c = "";
  for (i = 0; i < x.length; i++) {
    if (x[i] === x[i + 1]) {
      continue;
    } else {
      c += x[i];
    }
  }
  c = c.split("").sort();
  y = "";
  for (i = 0; i < c.length; i++) {
    if (c[i] === c[i + 1]) {
      y += c[i];
      break;
    } else {
      continue;
    }
  }
  if (y.length === 1) {
    print("NO");
  } else {
    print("YES");
  }
}

var test = parseInt(readline());

for(var i = 0; i < test; i++) {
    var counter = 0;
    var foo = parseInt(readline());
    var tasks = readline();
    var tasksSplited = tasks.split("")

    for(var j = 0; j < foo; j++) {
        for(var k = j + 1; k <= foo; k++) {
            if(tasksSplited[j] == tasksSplited[k] && k == j + 1) {
                break
            } else if(tasksSplited[j] == tasksSplited[k] && k != j + 1) {
                counter++
            }
        }
    } if(counter > 0) {
        print("NO")
    } else {
        print("YES")
    }
}

var t = parseInt(readline());

  function solve() {
    var n = parseInt(readline());
    var s = readline();
    var a = [];
    a[s[0].charCodeAt(0) - "A".charCodeAt(0)] = 1;
    for (var i = 1; i < n; i++) {
      if (s[i] == s[i - 1]) continue;
      else {
        if (a[s[i].charCodeAt(0) - "A".charCodeAt(0)] > 0) {
          return "NO";
        }
        a[s[i].charCodeAt(0) - "A".charCodeAt(0)] = 1;
      }
    }
    return "YES";
  }

  while (t--) {
    print(solve());
  }

var tests = Number(readline());

for (var i = 0; i < tests; i++) {
    var days = Number(readline());
    var str = readline();
    var sus = false;
    var arr = [];

    for (var j = 1; j <= days; j++) {
        if (str.charAt(j - 1) != str.charAt(j))
            arr.push(str.charAt(j-1));
        if (arr.includes(str.charAt(j)))
            sus = true;

    }
    sus ? print("NO") : print("YES");
}

// Input:
// t (number of test cases)
// n (number of letters)
// n following letters

// Output:
// YES/NO for every test case

// Algorithm:
// Non consecutive occurance of some letter => NO
// Otherwise, YES

function deleteConsecutiveRepetitions(str, len) {
    j = 0;
    output = str[0];
    for (var i = 0; i < len; ++i) {
        if (str[i] != output[j]) {
            output += str[i];
            ++j;
        }
    }
    return output;
}

function countOccurrence(str, letter) {
    count = 0;
    for (var i = 0; i < str.length; ++i) {
        if (str[i] == letter) {
            ++count;
        }
    }
    return count;
}

function solution(str) {
    for (letter of str) {
        if (countOccurrence(str, letter) > 1) {
            return "NO";
        }
    }
    return "YES";
}

answers = [];

t = +readline();
for (var i = 0; i < t; ++i) {
    n = +readline();
    x = deleteConsecutiveRepetitions(readline(), n);
    answers.push(solution(x));
}

for (answer of answers) {
    print(answer);
}

var t=parseInt(readline());

for(var i=0;i<t;i++)
{
    var n = parseInt(readline());
    var s = readline();
    var x=0;
    var m={};
    //print(s);

    for(var j=1;j<n;j++)
    {
        if(s[j]!=s[j-1] && m[s[j]]!=1)
        {
            m[s[j-1]]=1;
        }
        else if(s[j]!=s[j-1] && m[s[j]]==1)
        {
            x=1;
        }
    }
    if(x)
        print("NO");
    else
    print("YES");
}

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
var n = parseInt(readline());
var s = readline();
var meet = {};
var f = true;
meet[s[0]] = true;
var prev = s[0];

for (var i = 1; i < n && f; i++) {
if (s[i] !== prev && meet[s[i]])
f = false;
prev = s[i];
meet[s[i]] = true;
}

print(f? "YES": "NO");
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
	inputString += inputStdin;
});

process.stdin.on('end', _ => {
	inputString = inputString.trim().split('\n').map(string => {
		return string.trim();
	});

	main();
});

function readline() {
	return inputString[currentLine++];
}

function main() {
	var t = readline();
	let count = 1;
	while (count <= t) {
		let n = readline()
		var stringArray = Array.from(readline());
		let counter = 0;
		let arrayLength = stringArray.length
		for (let i = 0; i <= arrayLength; i++) {
			if (stringArray[i] === stringArray[i + 1]) {
				stringArray.splice(i, 1)
			}
		}

		for (let i = 0; i <= arrayLength; i++) {
			if (stringArray[i] === stringArray[i + 1]) {
				stringArray.splice(i, 1)
			}
		}
		const hasDuplicates = arr => arr.some((item, index) => arr.indexOf(item) !== index)
		if (hasDuplicates(stringArray)) {
			console.log("NO")
		}
		else {
			console.log("YES")

		}
		count++
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
	inputString += inputStdin;
});

process.stdin.on('end', _ => {
	inputString = inputString.trim().split('\n').map(string => {
		return string.trim();
	});

	main();
});

function readline() {
	return inputString[currentLine++];
}

function main() {
	var t = readline();
	let count = 1;
	while (count <= t) {
		readline()
		var stringArray = Array.from(readline());
		let counter = 0;
		let arrayLength = stringArray.length
		for (let i = 0; i < arrayLength; i++) {
			if (stringArray[i] === stringArray[i + 1]) {
				stringArray.splice(i, 1)
			}
		}

		for (let i = 0; i < arrayLength; i++) {
			if (stringArray[i] === stringArray[i + 1]) {
				stringArray.splice(i, 1)
			}
		}
		const hasDuplicates = arr => arr.some((item, index) => arr.indexOf(item) !== index)
		if (hasDuplicates(stringArray)) {
			console.log("NO")
		}
		else {
			console.log("YES")

		}
		count++
	}
}

let input = '';
process.stdin.on('data', (c) => {
    input += c;
});

process.stdin.on('end', () => {
    const lines = input.split('\n');
    const cases = parseInt(lines[0]);

    let prevLetter;
    let on = true;
    for (let i = 1; i < cases * 2 + 2; i++) {
        const line = lines[i];
        if (!line) return;
        if (!on) {
            const all = [];
            const chars = line.split('').map(t => t.trim()).filter(t => !!t);
            let dont = false;
            chars.forEach((char, index) => {
                const prev = line[index - 1];
                if (!all.includes(char)) {
                    all.push(char);
                } else if (all.includes(char) && prev !== char) {
                    console.log('NO');
                    dont = true;
                    return;
                }
            });

            if (!dont) console.log('YES');
        }

        on = !on;
    }
});

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

// cat input.txt | node script.js > output.txt
// Number.parseInt(string)
function main() {
    let t = Number.parseInt(readline()), n, s, d, alphabet, suspicious;
    while(t--) {
        n = Number.parseInt(readline());
        s = readline();
        d = s.substr(0, 1);
        for(let i = 1; i < n; ++i) {
            if(s.substr(i, i + 1) !== s.substr(i - 1, i)) d += s.substr(i, i + 1);
        }
        alphabet = {};
        suspicious = false;
        for(let i = 0; i < d.length; ++i) {
            if(alphabet.hasOwnProperty(d[i])) {
                suspicious = true;
            } else {
                alphabet[d[i]] = true;
            }
        }
        suspicious ? console.log('NO') : console.log('YES');
    }
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
let initialized=false,
    cache = [];

function fairWork(inp){
  cache.push(inp);

  if(cache.length === 2){

    for(let i=0, repeats={}; i<inp.length; i++){
      if( repeats[inp[i]] ){ console.log('current i: '+i+' inp:i '+inp[i]); cache = []; return 'NO' }
      if(inp[i] != inp[i+1]){ repeats[inp[i]] = true }
    }

    cache = [];
    return 'YES'
  }

}

rl.on('line', (input) => {
  if(initialized){ console.log( fairWork(input) ) }
  else initialized = true
});

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

        let testCases = parseInt(readLine());
        while(testCases--)
        {
            const n = parseInt(readLine());
            const s = readLine();
            let last = '';
            let solved = '';
            let flag = true;
            for(let i = 0 ; i < n; i++)
            {
                if(s[i] !== last && solved.includes(s[i]))
                {
                    print('NO');
                    flag = false;
                    break;
                }
                solved += s[i];
            }
            if (flag) print('YES');
        }

});

function print(c){
    return console.log(c);
}

function get_ints() {
    return readLine().split(' ').map(Number)
}

function readLine() {
        return data[currentLine++];
}

var q = Number(readline());

while (q--) {
    var n = Number(readline());
    var s = readline();
    var mapa={};
    mapa[s[0]]=true;
    var ans=false;
    for(var i=1;i<n;++i){
        if(mapa[s[i]]&&s[i]!==s[i-1]){
            print("NO");
            ans=true;
            break;
        }
    }
    if (!ans)
        print("YES");
}

var q = Number(readline());

while (q--) {
    var n = Number(readline());
    var s = readline();
    var mapa={};
    mapa[s[0]]=true;
    var ans=false;
    for(var i=1;i<n;++i){
        if(mapa[s[i]]&&s[i]!==s[i-1]){
            print("NO\n");
            ans=true;
            break;
        }
    }
    if (!ans)
        print("YES\n");
}

test = readline();

while (test--) {
    size = readline();
    tasks = readline();
    task = [tasks[0]];
    currentTask = tasks[0];
    flag = true
    for (var i = 1; i < size; i++) {
        if (currentTask === tasks[i]) {
            if(!task.includes(tasks[i])) {
                task.push(tasks[i])
            }
        } else {
            if(task.includes(tasks[i])) {
                flag = false
                break;
            }
            currentTask = tasks[i];
        }
    }
    print(flag ? "YES" : "NO")
}

var n = readline();
while(n--) {
    var len = readline();
    var str = readline();
    var store = [];
    var chck = 1;
    for(var i=0; i<len; i++){
        if(str[i+1] && str[i] != str[i+1]) {
            if(store.includes(str[i])) {
                chck = 0
                print("NO");
                break;
            }
            else {
                store.push(str[i])
            }
        }
    }
    if(chck) {
        print("YES")
    }

}

var t = +readline();

while (t--) {
    var n = +readline(); // number of days
    var tasks = readline();
    var taskSet = new Set();
    var answer = "NO";

    for(var i = 0; i < n; i++) {
        while (i + 1 < n && tasks[i + 1] == tasks[i]) {
            i++;
        }
        if(!taskSet.has(tasks[i])) {
            taskSet.add(tasks[i]);
        } else {
            answer = "YES";
            break;
        }
    }
    // print(Array.from(taskSet));
    print(answer);
}


Pasha loves to send strictly positive integers to his friends. Pasha cares about security, therefore when he wants to send an integer $$$n$$$, he encrypts it in the following way: he picks three integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$l \leq a,b,c \leq r$$$, and then he computes the encrypted value $$$m = n \cdot a + b - c$$$.Unfortunately, an adversary intercepted the values $$$l$$$, $$$r$$$ and $$$m$$$. Is it possible to recover the original values of $$$a$$$, $$$b$$$ and $$$c$$$ from this information? More formally, you are asked to find any values of $$$a$$$, $$$b$$$ and $$$c$$$ such that  $$$a$$$, $$$b$$$ and $$$c$$$ are integers,  $$$l \leq a, b, c \leq r$$$,  there exists a strictly positive integer $$$n$$$, such that $$$n \cdot a + b - c = m$$$.

The first line contains the only integer $$$t$$$ ($$$1 \leq t \leq 20$$$) — the number of test cases. The following $$$t$$$ lines describe one test case each. Each test case consists of three integers $$$l$$$, $$$r$$$ and $$$m$$$ ($$$1 \leq l \leq r \leq 500\,000$$$, $$$1 \leq m \leq 10^{10}$$$). The numbers are such that the answer to the problem exists.

For each test case output three integers $$$a$$$, $$$b$$$ and $$$c$$$ such that, $$$l \leq a, b, c \leq r$$$ and there exists a strictly positive integer $$$n$$$ such that $$$n \cdot a + b - c = m$$$. It is guaranteed that there is at least one possible solution, and you can output any possible combination if there are multiple solutions.

NoteIn the first example $$$n = 3$$$ is possible, then $$$n \cdot 4 + 6 - 5 = 13 = m$$$. Other possible solutions include: $$$a = 4$$$, $$$b = 5$$$, $$$c = 4$$$ (when $$$n = 3$$$); $$$a = 5$$$, $$$b = 4$$$, $$$c = 6$$$ (when $$$n = 3$$$); $$$a = 6$$$, $$$b = 6$$$, $$$c = 5$$$ (when $$$n = 2$$$); $$$a = 6$$$, $$$b = 5$$$, $$$c = 4$$$ (when $$$n = 2$$$).In the second example the only possible case is $$$n = 1$$$: in this case $$$n \cdot 2 + 2 - 3 = 1 = m$$$. Note that, $$$n = 0$$$ is not possible, since in that case $$$n$$$ is not a strictly positive integer.

function solve() {
   var lrm = readArray(Number);
   var l = lrm[0];
   var r = lrm[1];
   var m = lrm[2];
   var a, b, c, n;
   for (var i = l; i <= r; i++) {
      a = i;
      n = Math.floor(m / a);
      if (n > 0) {
         mod = m - a * n;
         if (mod <= r - l) {
            b = l + mod;
            c = l;
            break;
         }
      }
      n++;
      mod = a * n - m;
      if (mod <= r - l) {
         b = l;
         c = l + mod;
         break;
      }
   }
   write('' + a + ' ' + b + ' ' + c);
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function readArray(mapF) {
   return read().split(' ').map(mapF);
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const [l, r, m] = readLine().split(/\s/).map(Number)
        if (m <= l) {
            console.log(`${l} ${l} ${2 * l - m}`)
            continue
        }
        for (let a = l; a <= r; a++) {
            const mod = m % a
            const diff = Math.min(mod, a - mod)
            if (diff <= r - l) {
                console.log(`${a} ${mod === diff ? `${l + diff} ${l}` : `${l} ${l + diff}`}`)
                break
            }
        }
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    B();
});

function readline() {
    return inputString[currentLine++];
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function pi(x){
    return parseInt(x);
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [l,r,m] = ti(readline().split(' '));
        for(let a = l; a <= r; a++){
            let minN = Math.floor(m/a);
            let maxN = minN + 1;
            if(minN * a === m){
                console.log(a,a,a);
                break;
            }else{
                if(minN !== 0 && m-minN*a <= r-l){
                    console.log(a, l+(m-minN*a), l);
                    break;
                }else if(maxN*a - m <= r-l){
                    console.log(a, l, l+(maxN*a-m));
                    break;
                }
            }
        }
    }
}

function solve() {
   var lrm = readArray(BigInt);
   var l = lrm[0];
   var r = lrm[1];
   var m = lrm[2];
   var a, b, c, n;
   for (var i = l; i <= r; i++) {
      a = i;
      n = m / a;
      mod = m - a * n;
      if (mod <= r - l) {
         b = l + mod;
         c = l;
         break;
      }
      n++;
      mod = a * n - m;
      if (mod <= r - l) {
         b = l;
         c = l + mod;
         break;
      }
   }
   write('' + a + ' ' + b + ' ' + c);
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function readArray(mapF) {
   return read().split(' ').map(mapF);
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

function solve() {
   var lrm = readArray(BigInt);
   var l = lrm[0];
   var r = lrm[1];
   var m = lrm[2];
   var minn = 1n;
   var maxn = 2000000000n;
   var midn, minm, maxm;
   while (minn < maxn) {
      var midn = (minn + maxn) / 2n;
      minm = l * (midn + 1n) - r;
      maxm = r * (midn + 1n) - l;
      if (minm <= m && m <= maxm) {
         break;
      }
      if (m < minm) {
         maxn = midn;
      } else {
         minm = midn + 1;
      }
   }
   var a = m / midn;
   var mod = m - a * midn;
   var c = l;
   var b = l + mod;
   if (a * midn + b - c !== m) {
      a++;
      mod = a * midn - m;
      b = l;
      c = l + mod;
   }
   write('' + a + ' ' + b + ' ' + c);
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function readArray(mapF) {
   return read().split(' ').map(mapF);
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    B();
});

function readline() {
    return inputString[currentLine++];
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function pi(x){
    return parseInt(x);
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [l,r,m] = ti(readline().split(' '));
        for(let a = l; a <= r; a++){
            if(m % a === 0){
                console.log(a, a, a);
                break;
            }else{
                let x = m % a;
                if(x <= r-l){
                    if(m >= a){
                        console.log(a, a+x, a);
                        break;
                    }
                    else{
                        console.log(a, a, a+x);
                        break;
                    }
                }
            }
        }
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    B();
});

function readline() {
    return inputString[currentLine++];
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function pi(x){
    return parseInt(x);
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [l,r,m] = ti(readline().split(' '));
        for(let a = l; a <= r; a++){
            let minN = Math.floor(m/a);
            let maxN = minN + 1;
            if(minN * a === m){
                console.log(a,a,a);
                break;
            }else{
                if(minN !== 0 && m-minN*a <= r-l){
                    console.log(a, a+(m-minN*a), a);
                    break;
                }else if(maxN*a - m <= r-l){
                    console.log(a, a, a+(maxN*a-m));
                    break;
                }
            }
        }
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    B();
});

function readline() {
    return inputString[currentLine++];
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function pi(x){
    return parseInt(x);
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [l,r,m] = ti(readline().split(' '));
        for(let a = l; a <= r; a++){
            let minN = Math.floor(m/a);
            let maxN = minN + 1;
            if(minN * a === m){
                console.log(a,a,a);
                break;
            }else{
                if(m-minN*a <= r-l){
                    console.log(a, a+(m-minN*a), a);
                    break;
                }else if(maxN*a - m <= r-l){
                    console.log(a, a, a+(maxN*a-m));
                    break;
                }
            }
        }
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    B();
});

function readline() {
    return inputString[currentLine++];
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function pi(x){
    return parseInt(x);
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [l,r,m] = ti(readline().split(' '));
        for(let a = l; a <= r; a++){
            if(m % a === 0){
                console.log(a, a, a);
                break;
            }else{
                let x = m % a;
                if(x <= r-l){
                    console.log(a, a+x, a);
                    break;
                }
            }
        }
    }
}


Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the other chats doesn't change. If there was no chat with this friend before, then a new chat is simply inserted to the top of the list.Assuming that the chat list is initially empty, given the sequence of Polycaprus' messages make a list of chats after all of his messages are processed. Assume that no friend wrote any message to Polycarpus.

The first line contains integer n (1 ≤ n ≤ 200 000) — the number of Polycarpus' messages. Next n lines enlist the message recipients in the order in which the messages were sent. The name of each participant is a non-empty sequence of lowercase English letters of length at most 10.

Print all the recipients to who Polycarp talked to in the order of chats with them, from top to bottom.

8
alina
maria
ekaterina
darya
darya
ekaterina
maria
alina

NoteIn the first test case Polycarpus first writes to friend by name "alex", and the list looks as follows:   alex Then Polycarpus writes to friend by name "ivan" and the list looks as follows:  ivan  alex Polycarpus writes the third message to friend by name "roman" and the list looks as follows:  roman  ivan  alex Polycarpus writes the fourth message to friend by name "ivan", to who he has already sent a message, so the list of chats changes as follows:  ivan  roman  alex

    var names = [];
    var n = +readline();
    for (var i = 0; i < n; i++) {
        names.push(readline())
    }
    var keys = {};
    var result = [];
    for (i = 0; i < names.length; i++) {
        var name = names[i];
        keys[name] = i;
    }
    Object.keys(keys).forEach(function(item) {
       result[keys[item]] = item;
    });

    for (var j = i; j >= 0; j--) {
        if (result[j]) {
            print(result[j])
        }
    }

var l = readline().split(' ');
var n = +l[0];
var a = [];
for (var i = 0; i < n; i++) {
	a.push(readline());
}
var dat = {
};
var list = [];
for (var i = a.length - 1; i >= 0; i--) {
	if(!dat[a[i]]){
		dat[a[i]] = true;
		list.push(a[i]);
	}
}
print(list.join('\n'));

var messageCount = +readline(),
    messageList = [];

for (var i = 0; i<messageCount; i++){
    messageList.push(readline());
}
messageList.reverse();

messageList = new Set(messageList);
messageList.forEach(function(el){
    print(el);
});

var readInt = () => parseInt(readline())
var readIntArray = () => readline().split(' ').map(item => parseInt(item))

var n = readInt()
var input = []
for(var i = 0; i < n; i++)
    input[i] = readline()

var nameSet = {}
for (var i = n-1; i >= 0; i--){
    if (!nameSet[input[i]]) {
        nameSet[input[i]] = true
        print(input[i])
    }
}

N = parseInt(readline())

I = []

for(var i=0;i<N;i++)
I.push(readline())

D={}

for(i=N-1;i>=0;i--){
if(!D[I[i]]){
print(I[i])
D[I[i]]=true
}}

function main() {
    var names = [];
    var n = +readline();
    for (var i = 0; i < n; i++) {
        names.push(readline())
    }
    var keys = {};
    var result = [];
    for (i = 0; i < names.length; i++) {
        var name = names[i];
        keys[name] = i;
    }
    Object.keys(keys).forEach(function(item) {
       result[keys[item]] = item;
    });

    var res = "";
    for (i; i >= 0; i--) {
        if (result[i]) {
            res += result[i] + "\n"
        }
    }
    print(res);
}

var l = readline().split(' ');
var n = +l[0];
var a = [];
for (var i = 0; i < n; i++) {
	a.push(readline());
}
var dat = {
};
var list = [];
for (var i = a.length - 1; i >= 0; i--) {
	if(!dat[a[i]]){
		dat[a[i]] = true;
		list.unshift(a[i]);
	}
}
print(list.join('\n'));

N = parseInt(readline())

I = Array()

for(var i=0;i<N;i++)
I.push(readline())

D=Array()

for(i=N-1;i>=0;i--){
if(D.indexOf(I[i])!=-1){
D.push(I[i])
print(I[i])
}
}

N = parseInt(readline())

I = Array()

for(var i=0;i<N;i++)
I.push(readline())

D=Array()

for(i=N-1;i>=0;i--){
if(D.indexOf(I[i])!=-1){
D.push(I[i])
write(I[i] + '\n')
}
}


There are $$$n$$$ logs, the $$$i$$$-th log has a length of $$$a_i$$$ meters. Since chopping logs is tiring work, errorgorn and maomao90 have decided to play a game.errorgorn and maomao90 will take turns chopping the logs with errorgorn chopping first. On his turn, the player will pick a log and chop it into $$$2$$$ pieces. If the length of the chosen log is $$$x$$$, and the lengths of the resulting pieces are $$$y$$$ and $$$z$$$, then $$$y$$$ and $$$z$$$ have to be positive integers, and $$$x=y+z$$$ must hold. For example, you can chop a log of length $$$3$$$ into logs of lengths $$$2$$$ and $$$1$$$, but not into logs of lengths $$$3$$$ and $$$0$$$, $$$2$$$ and $$$2$$$, or $$$1.5$$$ and $$$1.5$$$.The player who is unable to make a chop will be the loser. Assuming that both errorgorn and maomao90 play optimally, who will be the winner?

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 50$$$)  — the number of logs. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 50$$$)  — the lengths of the logs. Note that there is no bound on the sum of $$$n$$$ over all test cases.

For each test case, print "errorgorn" if errorgorn wins or "maomao90" if maomao90 wins. (Output without quotes).

NoteIn the first test case, errorgorn will be the winner. An optimal move is to chop the log of length $$$4$$$ into $$$2$$$ logs of length $$$2$$$. After this there will only be $$$4$$$ logs of length $$$2$$$ and $$$1$$$ log of length $$$1$$$.After this, the only move any player can do is to chop any log of length $$$2$$$ into $$$2$$$ logs of length $$$1$$$. After $$$4$$$ moves, it will be maomao90's turn and he will not be able to make a move. Therefore errorgorn will be the winner.In the second test case, errorgorn will not be able to make a move on his first turn and will immediately lose, making maomao90 the winner.

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var e = 0;
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number);
            var f = 0;
            for(l = 0; l < e; l++){
                if(k[l] % 2 == 1){
                    continue;
                }else{
                    if(f === 0){
                        f = 1;
                    }else{
                        f = 0;
                    }
                }
            }
            if(f === 0){
                console.log('maomao90');
            }else{
                console.log('errorgorn');
            }
        }
    }
});

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var n = lines[0];
    var e = 0;
    for(i = 1; i <= n * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var turn = 0;
            for(j = 0; j < e; j++){
                if(k[j] % 2 == 1){
                    continue;
                }else{
                    if(turn === 0){
                        turn = 1;
                    }else{
                        turn = 0;
                    }
                }
            }
            if(turn === 0){
                console.log('maomao90');
            }else{
                console.log('errorgorn');
            }
        }
    }
});

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', stdin => inputString += stdin);

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(s => s.trim());
    main();
});

function readline() {
    return inputString[currentLine++];
}

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);
        let arr = readline().split(' ').map(Number);
        let sum = arr.map(x => x - 1).reduce((a, b) => a + b, 0);

        output((sum % 2 === 1) ? 'errorgorn' : 'maomao90');
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

const players = ['maomao90', 'errorgorn']

function main() {
  let t = parseInt(readline())
  while (t--) {
    let n = parseInt(readline())
    let as = readline().split(' ').map(x => parseInt(x))
    let loser = 0
    as.forEach(a => {
      loser += a - 1
    });
    console.log(players[loser % 2])
  }
}

const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];
let T;

function parseInput() {
  T = parseInt(input[0]);
  let index = 0;

  for (let i = 0; i < T; i++) {
    index++;
    const n = parseInt(input[index]);
    index++;
    const a = input[index].split(" ").map((item) => parseInt(item));
    const testCase = {
      n,
      a,
    };
    testCases.push(testCase);
  }
}

function solution(testCase, index) {
  const { n, a } = testCase;

  let result = 0;

  a.forEach((v) => (result += v - 1));

  console.log(result % 2 ? "errorgorn" : "maomao90");
}

parseInput();

testCases.forEach(solution);

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, a) {
  let res = 0;
  for (let b of a) {
    res += b - 1;
  }
  if (res & 1) console.log('errorgorn');else console.log('maomao90');
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const n = Number(await read());
    const a = (await read()).split(' ').map(Number);
    solve(n, a);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let ls = [];

function solve() {
    let l = 0;
    const t = parseInt(ls[l++]);
    for (let i = 0; i < t; i++){
        const n = parseInt(ls[l++]);
        const a = ls[l++].split(' ').map(it => parseInt(it));
        let sum = 0;
        for (let j = 0; j < n; j++){
            if (a[j] > 1){
                sum += a[j] - 1;
            }
        }
        if (sum % 2 == 0){
            console.log('maomao90');
        }
        else{
            console.log('errorgorn');
        }
    }
}

rl.on('line', (l) => ls.push(l));
rl.on('close', () => solve());

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var e = 0;
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number);
            var f = false;
            for(l = 0; l < e; l++){
                if(k[l] % 2 == 1){
                    continue;
                }else{
                    if(f === 0){
                        f = true;
                    }else{
                        f = false;
                    }
                }
            }
            if(f === false){
                console.log('maomao90');
            }else{
                console.log('errorgorn');
            }
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var e = 0;
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number);
            var f = false;
            for(l = 0; l < e; l++){
                if(k[l] % 2 == 1){
                    continue;
                }else{
                    if(f === 0){
                        f = true;
                    }else{
                        f = false;
                    }
                }
            }
            if(f === 0){
                console.log('maomao90');
            }else{
                console.log('errorgorn');
            }
        }
    }
});


Nikolay lives in a two-storied house. There are $$$n$$$ rooms on each floor, arranged in a row and numbered from one from left to right. So each room can be represented by the number of the floor and the number of the room on this floor (room number is an integer between $$$1$$$ and $$$n$$$). If Nikolay is currently in some room, he can move to any of the neighbouring rooms (if they exist). Rooms with numbers $$$i$$$ and $$$i+1$$$ on each floor are neighbouring, for all $$$1 \leq i \leq n - 1$$$. There may also be staircases that connect two rooms from different floors having the same numbers. If there is a staircase connecting the room $$$x$$$ on the first floor and the room $$$x$$$ on the second floor, then Nikolay can use it to move from one room to another.     The picture illustrates a house with $$$n = 4$$$. There is a staircase between the room $$$2$$$ on the first floor and the room $$$2$$$ on the second floor, and another staircase between the room $$$4$$$ on the first floor and the room $$$4$$$ on the second floor. The arrows denote possible directions in which Nikolay can move. The picture corresponds to the string "0101" in the input.  Nikolay wants to move through some rooms in his house. To do this, he firstly chooses any room where he starts. Then Nikolay moves between rooms according to the aforementioned rules. Nikolay never visits the same room twice (he won't enter a room where he has already been). Calculate the maximum number of rooms Nikolay can visit during his tour, if:  he can start in any room on any floor of his choice,  and he won't visit the same room twice.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of two lines. The first line contains one integer $$$n$$$ $$$(1 \le n \le 1\,000)$$$ — the number of rooms on each floor. The second line contains one string consisting of $$$n$$$ characters, each character is either a '0' or a '1'. If the $$$i$$$-th character is a '1', then there is a staircase between the room $$$i$$$ on the first floor and the room $$$i$$$ on the second floor. If the $$$i$$$-th character is a '0', then there is no staircase between the room $$$i$$$ on the first floor and the room $$$i$$$ on the second floor. In hacks it is allowed to use only one test case in the input, so $$$t = 1$$$ should be satisfied.

For each test case print one integer — the maximum number of rooms Nikolay can visit during his tour, if he can start in any room on any floor, and he won't visit the same room twice.

NoteIn the first test case Nikolay may start in the first room of the first floor. Then he moves to the second room on the first floor, and then — to the third room on the first floor. Then he uses a staircase to get to the third room on the second floor. Then he goes to the fourth room on the second floor, and then — to the fifth room on the second floor. So, Nikolay visits $$$6$$$ rooms.There are no staircases in the second test case, so Nikolay can only visit all rooms on the same floor (if he starts in the leftmost or in the rightmost room).In the third test case it is possible to visit all rooms: first floor, first room $$$\rightarrow$$$ second floor, first room $$$\rightarrow$$$ second floor, second room $$$\rightarrow$$$ first floor, second room $$$\rightarrow$$$ first floor, third room $$$\rightarrow$$$ second floor, third room $$$\rightarrow$$$ second floor, fourth room $$$\rightarrow$$$ first floor, fourth room $$$\rightarrow$$$ first floor, fifth room $$$\rightarrow$$$ second floor, fifth room.In the fourth test case it is also possible to visit all rooms: second floor, third room $$$\rightarrow$$$ second floor, second room $$$\rightarrow$$$ second floor, first room $$$\rightarrow$$$ first floor, first room $$$\rightarrow$$$ first floor, second room $$$\rightarrow$$$ first floor, third room.

    'use strict'

    const problem = (n, a) => {
        const i1 = a.indexOf('1');
        if (i1 === -1) return n;
        return 2*Math.max(n - a.indexOf('1'), a.lastIndexOf('1') + 1);
    }

    let t = parseInt(readline());
    while (t--) {
        write(problem(parseInt(readline()), readline()) + '\n');
    }

var queriesCount = parseInt(readline());
var queries = [];

for (var i = 0; i < queriesCount; i++) {
  var rooms = readline();
  queries.push(
    readline().split('').map(function(num) {
      return parseInt(num);
    })
  )
}

function min(a, b, c) {
  return ((a < b) && (a < c)) ? a : ((b < a) && (b < c)) ? b : c;
}

// var queriesCount = 4;
// var queries = [
//   [0,0,1,0,0],
//   [0,0,0,0,0,0,0,0],
//   [1,1,1,1,1],
//   [1,1,0]
// ]

function main(query) {
  var oneExists = 0;
  var minDistance = Infinity;
  for (var i = 0; i < query.length; i++) {
    if (query[i] === 1) {
      oneExists++;
      minDistance = min(minDistance, i - 0, query.length - i - 1);
    }
  }

  if (!oneExists)
    write([query.length].join('') + '\n')
  else
    write([(query.length - minDistance)*2].join('') + '\n');
}

for (var i = 0; i < queriesCount; i++) {
  main(queries[i]);
}

const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let t, n, lp = 0;

rl.on('line', (input) => {
    if (lp === 0){
        lp = 1;
        t = parseInt(input) * 2;
    } else if (lp === 1){
        lp = 2;
        n = input;
    } else if (lp === 2){
        lp = 1;
        let x = input;
        let prv = 0, nxt = 0;
        for (let i = 0; i < x.length; i++)if (x.charAt(i) === '1')nxt = i + 1;
        for (let i = x.length - 1; i >= 0; i--)if (x.charAt(i) === '1')prv = x.length - i;
        let an;
        if (prv === 0 && nxt === 0)an = x.length; else an = Math.max(prv, nxt) * 2;
        console.log(an);
    }
    if (t === 0)rl.close();
    t--;
});

'use strict'

const problem = (n, a) => {
    const i1 = a.indexOf('1');
    if (i1 === -1) return n;
    return 2*Math.max(n - a.indexOf('1'), a.lastIndexOf('1'));
}

let t = parseInt(readline());
while (t--) {
    write(problem(parseInt(readline()), readline()) + '\n');
}

var queriesCount = parseInt(readline());
var queries = [];

for (var i = 0; i < queriesCount; i++) {
  var rooms = readline();
  queries.push(
    readline().split('').map(function(num) {
      return parseInt(num);
    })
  )
}

function min(a, b, c) {
  return ((a < b) && (a < c)) ? a : ((b < a) && (b < c)) ? b : c;
}

// var queriesCount = 4;
// var queries = [
//   [0,0,1,0,0],
//   [0,0,0,0,0,0,0,0],
//   [1,1,1,1,1],
//   [1,1,0]
// ]

function main(query) {
  var oneExists = 0;
  var minDistance = Infinity;
  for (var i = 0; i < query.length; i++) {
    if (query[i] === 1) {
      oneExists++;
      minDistance = min(minDistance, i - 0, query.length - i - 1);
    }
  }

  if (!oneExists)
    write([query.length].join(''))
  else
    write([(query.length - minDistance)*2].join(''));
}

for (var i = 0; i < queriesCount; i++) {
  main(queries[i]);
}

const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let t, n, lp = 0;

rl.on('line', (input) => {
    if (lp === 0){
        lp = 1;
        t = parseInt(input) * 2;
    } else if (lp === 1){
        lp = 2;
        n = input;
    } else if (lp === 2){
        lp = 1;
        let x = input;
        let prv = 0, nxt = 0;
        for (let i = 0; i < x.length; i++)if (x.charAt(i) === '1')nxt = i + 1;
        for (let i = x.length; i >= 0; i--)if (x.charAt(i) === '1')prv = x.length - i;
        let an = Math.max(prv, nxt) * 2;
        console.log(an);
    }
    if (t === 0)rl.close();
    t--;
});