Ela loves reading a lot, just like her new co-workers in DTL! On her first day after becoming an engineer in DTL, she is challenged by a co-worker to sort a heap of books into different compartments on the shelf.$$$n$$$ books must be split into $$$k$$$ compartments on the bookshelf ($$$n$$$ is divisible by $$$k$$$). Each book is represented by a lowercase Latin letter from 'a' to 'y' inclusively, which is the beginning letter in the title of the book.Ela must stack exactly $$$\frac{n}{k}$$$ books in each compartment. After the books are stacked, for each compartment indexed from $$$1$$$ to $$$k$$$, she takes the minimum excluded (MEX) letter of the multiset of letters formed by letters representing all books in that compartment, then combines the resulting letters into a string. The first letter of the resulting string is the MEX letter of the multiset of letters formed by the first compartment, the second letter of the resulting string is the MEX letter of the multiset of letters formed by the second compartment, ... and so on. Please note, under the constraint of this problem, MEX letter can always be determined for any multiset found in this problem because 'z' is not used.What is the lexicographically greatest resulting string possible that Ela can create?A string $$$a$$$ is lexicographically greater than a string $$$b$$$ if and only if one of the following holds:  $$$b$$$ is a prefix of $$$a$$$, but $$$b \ne a$$$;  in the first position where $$$a$$$ and $$$b$$$ differ, the string $$$a$$$ has a letter that appears later in the alphabet than the corresponding letter in $$$b$$$. The minimum excluded (MEX) letter of a multiset of letters is the letter that appears earliest in the alphabet and is not contained in the multiset. For example, if a multiset of letters contains $$$7$$$ letters 'b', 'a', 'b', 'c', 'e', 'c', 'f' respectively, then the MEX letter of this compartment is 'd', because 'd' is not included in the multiset, and all letters comes before 'd' in the alphabet, namely 'a', 'b' and 'c', are included in the multiset.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 200$$$; $$$1 \le k \le n$$$). It is guaranteed that $$$n$$$ is divisible by $$$k$$$. The second line of each test case contains a string of $$$n$$$ lowercase Latin letters from 'a' to 'y' inclusively. Each letter represents the starting letter of the title of a book in the initial heap. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$.

For each test case, output a string of $$$k$$$ letters which is the most optimal string that Ela can find.

5

12 3

cabccadabaac

12 6

cabccadabaac

12 12

cabccadabaac

25 1

abcdefghijklmnopqrstuvwxy

10 5

bcdxedbcfg

NoteIn the first test case, the books can be divided into $$$3$$$ compartments as below:  the first compartment contains the books with indices $$$1, 2, 3, 7$$$: $$$multiset_1 = \{$$$'c', 'a', 'b', 'd'$$$\}$$$ $$$\rightarrow$$$ $$$MEX(multiset_1) =$$$ 'e'  the second compartment contains the books with indices $$$4, 5, 6, 9$$$ : $$$multiset_2 = \{$$$'c', 'c', 'a', 'b'$$$\}$$$ $$$\rightarrow$$$ $$$MEX(multiset_2) =$$$ 'd'  the third compartment contains the remaining books $$$8, 10, 11, 12$$$ : $$$multiset_3 = \{$$$ 'a', 'a', 'a', 'c'$$$\}$$$ $$$\rightarrow$$$ $$$MEX(multiset_3) =$$$ 'b' Therefore, the answer is 'edb'. It can be proven that there is no way that Ela can arrange the books so that it results in a lexicographically greater string.

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        const n_k = readLine().split(' ').map(p => +p);
        const str = readLine();
        let result = myFunc(n_k[0], n_k[1], str);
        console.log(result);
    }
}

function myFunc(n, k, s){
    let sub = n/k;
    let map = [];
    const alfabeto = 'abcdefghijklmnopqrstuvwxyz';
    let resp = '';

    function _num(s){
        return s.charCodeAt(0)-97;
    }

    for(let i = 0; i < n; i++){
        if(map[_num(s[i])] == undefined) map[_num(s[i])] = 1;
        else map[_num(s[i])]++;
    }

    for(let j = 0; j < k; j++){
        for(let i = 0; i < sub; i++){
            if(map[i]){
                map[i]--;
                if(i == sub-1) resp += alfabeto[sub];
            }
            else{
                resp+= alfabeto[i];
                break;
            }

        }
    }
    return resp;

}

function solve() {
    var letters = initValues();
    var [n, k] = readArray(Number);
    var s = read();
    var lettersCounter = new Map();
    letters.forEach((letter) => lettersCounter.set(letter, 0));
    for (var i = 0; i < n; i++) {
        lettersCounter.set(s[i], lettersCounter.get(s[i]) + 1);
    }
    const booksCounter = n / k;
    var ans = '';
    for (var i = 0; i < k; i++) {
        var MEXIndex = 0;
        for (MEXIndex = 0; MEXIndex < booksCounter; MEXIndex++) {
            var letter = letters[MEXIndex];
            if (lettersCounter.get(letter) === 0) {
                break;
            }
            lettersCounter.set(letter, lettersCounter.get(letter) - 1);
        }
        ans += letters[MEXIndex];
    }
    write(ans);
}

var initialValues;
function initValues() {
    if (initialValues) {
        return initialValues;
    }
    var letters = [];
    var aCode = 'a'.charCodeAt(0);
    var zCode = 'z'.charCodeAt(0);
    for (var i = aCode; i <= zCode; i++) {
        letters.push(String.fromCharCode(i));
    }
    initialValues = letters;
    return letters;
}

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

try {
    initInput(start);
} catch (e) {
    console.log(e);
}

var MEMORY;
var MEMORY_INDEX;
function readArray(f) {
    return read().split(' ').map(f);
}
var ANS;
// вывод через ANS быстрее, но ест кучу памяти.
// К тому же, максимальная длина строки - 2097151.
function write(value) {
    // console.log(value);
    ANS += value + '\n';
}
function writeAns() {
    if (ANS) {
        console.log(ANS);
    }
}
function read() {
    return MEMORY[MEMORY_INDEX++];
}
function initInput(callback) {
    var fs = require('fs');
    ANS = '';
    MEMORY_INDEX = 0;
    var isLocalStart = process.argv[2] === 'lorelvate';
    if (!isLocalStart) {
        MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
        callback();
        return;
    }
    var path = require('path');
    fs.readFile(path.join(__dirname, 'input.txt'), 'utf8', (err, data) => {
        if (err) {
            write(err);
            return;
        }
        MEMORY = data.split('\r\n');
        callback();
    });
}

'use strict';

var fs = require('fs');

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

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        k = rn(),
        s = read();
  const chs = s.split('').sort((a, b) => a === b ? 0 : a < b ? -1 : 1);
  const res = [];
  const vis = new Array(n);
  for (let i = 0; i < k; i++) {
    let cnt = 0;
    let pre = 96;
    for (let j = 0; j < n && cnt < n / k; j++) {
      const num = chs[j].charCodeAt(0);
      if (vis[j] || num === pre) continue;
      vis[j] = 1;
      cnt++;
      if (num === pre + 1) {
        pre = num;
      } else {
        if (res[i] === undefined) res[i] = pre + 1;
      }
    }
    if (res[i] === undefined) res[i] = pre + 1;
  }
  return res.map(num => String.fromCharCode(num)).join('');
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn();
    return res;
  };
  const re = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn() - 1;
    return res;
  };
  const rbs = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rb();
    return res;
  };
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  const [rn, rb, rns, re, rbs] = convertInput(r);
  try {
    let t = rn();
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8')
.split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();


The string $$$s$$$ is given, the string length is odd number. The string consists of lowercase letters of the Latin alphabet.As long as the string length is greater than $$$1$$$, the following operation can be performed on it: select any two adjacent letters in the string $$$s$$$ and delete them from the string. For example, from the string "lemma" in one operation, you can get any of the four strings: "mma", "lma", "lea" or "lem" In particular, in one operation, the length of the string reduces by $$$2$$$.Formally, let the string $$$s$$$ have the form $$$s=s_1s_2 \dots s_n$$$ ($$$n>1$$$). During one operation, you choose an arbitrary index $$$i$$$ ($$$1 \le i < n$$$) and replace $$$s=s_1s_2 \dots s_{i-1}s_{i+2} \dots s_n$$$.For the given string $$$s$$$ and the letter $$$c$$$, determine whether it is possible to make such a sequence of operations that in the end the equality $$$s=c$$$ will be true? In other words, is there such a sequence of operations that the process will end with a string of length $$$1$$$, which consists of the letter $$$c$$$?

The first line of input data contains an integer $$$t$$$ ($$$1 \le t \le 10^3$$$) — the number of input test cases. The descriptions of the $$$t$$$ cases follow. Each test case is represented by two lines:   string $$$s$$$, which has an odd length from $$$1$$$ to $$$49$$$ inclusive and consists of lowercase letters of the Latin alphabet;  is a string containing one letter $$$c$$$, where $$$c$$$ is a lowercase letter of the Latin alphabet.

For each test case in a separate line output:  YES, if the string $$$s$$$ can be converted so that $$$s=c$$$ is true; NO otherwise.  You can output YES and NO in any case (for example, the strings yEs, yes, Yes and YES will be recognized as a positive response).

5

abcde

c

abcde

b

x

y

aaaaaaaaaaaaaaa

a

contest

t

NoteIn the first test case, $$$s$$$="abcde". You need to get $$$s$$$="c". For the first operation, delete the first two letters, we get $$$s$$$="cde". In the second operation, we delete the last two letters, so we get the expected value of $$$s$$$="c".In the third test case, $$$s$$$="x", it is required to get $$$s$$$="y". Obviously, this cannot be done.

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    // console.log(line);
    for(let i=1;i<=2*t;i+=2)
    {
        let s=line[i];
        let c=line[i+1];
        // console.log(s.length,c.length);
        let flag=false;
        if(s.length%2==1)
        {
            for(let j=0;j<s.length;j++)
            {
                if(s[j]===c[0])
                {
                    if(j%2==0)
                    {
                        flag=true;
                    }
                }
            }
        }
        if(flag) console.log("YES");
        else console.log("NO");
    }
})

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL} = require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    // console.log(line);
    for(let i=1;i<=2*t;i+=2)
    {
        let s=line[i];
        let c=line[i+1];
        // console.log(s.length,c.length);
        let flag=false;
        if(s.length%2==1)
        {
            for(let j=0;j<s.length;j++)
            {
                if(s[j]===c[0])
                {
                    if(j%2==0)
                    {
                        flag=true;
                    }
                }
            }
        }
        if(flag) console.log("YES");
        else console.log("NO");
    }
})

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    let line=buf.split('\n');
    let t=parseInt(line[0]);
    for(let i=1;i<=2*t;i+=2)
    {
        let s=line[i];
        let c=line[i+1];
        s.length-=1,c.length-=1;
        // console.log(s.length,c.length);
        let flag=false;
        if(s.length%2==0)
        {
            for(let j=0;j<s.length-1;j++)
            {
                if(s[j]===c[0])
                {
                    if(j%2==0)
                    {
                        flag=true;
                    }
                }
            }
        }
        if(flag) console.log("YES");
        else console.log("NO");
    }
})

/*
** Template
*/

// 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) => {
            return string.trim();
        });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

const isOdd = (x) => { return x & 1 }
const isEven = (x) => { return !(x & 1) }

const getMiddle = s => s.substr(s.length - 1 >>> 1, (~s.length & 1) + 1)

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 getResult = ( str, target ) => {

    let len = str.length

    let validLen = []
    for(let i = 5; i <= len; i+= 4) validLen.push(i)

    if( len === 1 ) return str === target ? 'YES'  : 'NO'

    let begin   = str.charAt(0)
    let end     = str.charAt(str.length-1)
    let midchar = getMiddle(str)

    if( begin === target || end === target ) return 'YES'
    // if( midchar === target ){
    //     return validLen.includes(len) ? 'YES' : 'NO'
    // }

    let indices = findAllIndicesOfChar( str, target )

    for(let i = 0; i < indices.length; i++){
        if( isEven(indices[i]) ) {
            return 'YES'
        }
    }

    return 'NO'
}

function main() {
    let testcases = parseInt( readline() )
    while( testcases-- ){

        let str     = readline()
        let target  = readline()
        console.log( getResult( str, target ) )
    }
}
//*/

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
   var t = lines[0];
	var k = 0;
	for(i = 1; i <= t * 2; i++){
	    if(i % 2 == 1){
	       	 k = lines[i].split('');
	    }else{
	        var e = lines[i];
	        var a = false;
	        for(j = 0; j < k.length; j++){
	            if(k[j] == e){
	                if(j % 2 === 0){
	                    a = true;
	                }else{
	                    continue;
	                }
	            }
	        }
	        if(a){
	           console.log('YES');
	        }else{
	            console.log('NO');
	        }
	    }
	}
});

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 = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let s = nl.line().split('').map((e,i) => (i%2 == 0)?e:'').join('');
		let c = nl.line();
		ans.push(s.search(c) != -1);

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

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

'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 s = readline();
        let c = readline();

        let indexes = [];
        for (let i = 0; i < s.length; i++) {
            if (s[i] === c) indexes.push(i);
        }

        let no = true;
        for (let idx = 0; idx < indexes.length; idx++) {
            let i = indexes[idx];
            let rem = s.length - 1;
            if (i % 2 === 0 && rem % 2 === 0) {
                no = false;
                continue;
            }
        }

        output(no ? 'NO' : 'YES');
    }
}

'use strict'; /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const EPS = 1e-6;

const calc = (s, c)=>{
  for (let i=0; i<s.length; i++)
    if (i%2==0 && s[i]==c)
      return true;
};

function main() {
    let T = +readline()
    while (T--){
      let s = readline();
      let c = readline();
      print(calc(s, c) ? 'YES' : 'NO');
    }
}

E.calc = calc;

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

let c = 0;
let str;

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

  if (c % 2 === 1) {
    str = d;
    c++;
    return;
  }

  let ans = "NO";
  for (let i = 0; i < str.length; i++) {
    if (str[i] === d && i % 2 === 0) {
      ans = "YES";
    }
  }

  console.log(ans);
  c++;
});

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

const readline = require('readline');

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

let t = -1;
let i = 0;

let input = [];

function check(str1, c) {
    for (let i = 2; i < str1.length - 2; ++i) {
        if ((str1[i] === c) && (i % 2 === 0) && ((str1.length - i) % 2 !== 0)) {
            return true;
        }
    }

    if ((str1[str1.length - 1] === c) || (str1[0] === c)) {
        return true;
    } else {
        return false;
    }
}

rl.on('line', (line) => {
    if (t === -1) {
        t = parseInt(line);
    } else {
        ++i;

        input.push(line);

        if (i === 2 * t) {
            rl.close();
        }
    }
}).on('close', () => {
    for (let i = 0; i < input.length; i += 2) {
        if (check(input[i], input[i + 1])) {
            process.stdout.write("YES\n");
        } else {
            process.stdout.write("NO\n");
        }
    }

});

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

let ls = [];

function solve(){
    let i = 1;
    while (i < ls.length){
        const str = ls[i++];
        const c = ls[i++];
        let found = false;
        for (let j = 0; j < str.length; j++){
            if (str[j] == c && j % 2 == 0){
                found = true;
                break;
            }
        }
        console.log(found ? 'YES' : 'NO');
    }
}

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

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        solve();
    }
}
function solve() {
    let str = readLine();
    const c = readLine();
    for (let i = 0; i < str.length; i++) {
        if (i % 2 == 0 && str.charAt(i) === c) {
            console.log("YES");
            return;
        }
    }
    console.log("NO");
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const str = lines[l++]
        const c = lines[l++]
        output[i] = solve(str, c) ? 'YES' : 'NO'
    }
    console.log(output.join('\n'))
// })()
})

function solve(str, c) {
    for (let i = 0; i < str.length; i++) {
        if (str[i] === c && !(i & 1)) return true
    }
    return false
}

function solve() {
   const s = read();
   const c = read();
   for (let i = 0; i < s.length; i++) {
      if (s[i] === c && !(i & 1)) {
         write('YES');
         return;
      }
   }
   write('NO');
}

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

function pDivCount(n) {
   let ans = 0;
   let i = 1;
   while(n > 1) {
      i++;
      while(n % i === 0) {
         ans++;
         n = Math.floor(n / i);
      }
   }
   return ans;
}

function gcd(a, b) {
   if (a === 0) {
      return b;
   }
   return gcd(b % a, a);
}

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

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

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   MEMORY = fs.readFileSync(inTextName ? require('path').join(__dirname, inTextName) : 0, 'utf8').split('\r\n');
}
init();

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

//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 if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
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();
	while(hasNext()){
		var s = next();
		var N = s.length;
		var c = next();
		var ok = false;
		for(var i = 0; i < N; i += 2){
			if(s[i] == c){
				ok = true;
				break;
			}
		}
		myout((ok) ? "YES" : "NO");
	}
}

T = readline ()
while(T--){

   s = readline().split('')
   c = readline()
   res = 'NO'

   for(i=0; i< s.length; i++){
      if(s[i] ===c){
         if(i % 2 == 0 && (s.length - i) %2 != 0){
            res = 'YES'
            break
         }
      }
   }

   print(res)
}

var t = readline();
for (var i = 0; i<t; i++) {
     var str = readline();
     var letter = readline();
   print(fn(str,letter));
}

function fn(str, letter) {
    if (str === letter) return "YES";
    var arr = str.split('');
    var result;
    if (arr.length <= 1) return "NO";
     for (var i=0; i < arr.length; i++) {
         if (arr[i] === letter && i%2 === 0) {
             result="YES";
             break;
         }
         else result="NO";
         }
         return result;
  }

var t = readline()
for (var i = 0; i<t; i++) {
     var str = readline()
     var letter = readline()
   print(fn(str,letter))
}

function fn(str, letter) {
    if (str === letter) return "YES"
    var arr = str.split('')
    var result;
    if (arr.length <= 1) return "NO"
     for (var i=0; i < arr.length; i++) {
         if (arr[i] === letter && i%2 === 0) {
             result="YES"
             break;
         }
         else result="NO"
         }
         return result
  }

var tests =parseInt(readline());
for(var i=0 ; i<tests ; i++){
    var w  =readline();//abcde
    var c  =readline();//c
    if(c===w){
        print("YES")
    }
    else{
        var flg;
        for(var y=0 ; y<w.length ; y++){
            if(c === w[y] && y%2 === 0 ){
                flg = "YES";
                break;

            }
            else{
                flg="NO";
            }
        }
        print(flg)

    }

    }

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    let line=buf.split('\n');
    let t=parseInt(line[0]);
    for(let i=1;i<=2*t;i+=2)
    {
        let s=line[i];
        let c=line[i+1];
        s.length--;
        c.length--;
        let flag=false;
        if(s.length%2==1)
        {
            for(let j=0;j<s.length;j++)
            {
                if(s[j]===c)
                {
                    if(j%2==0)
                    {
                        flag=true;
                    }
                }
            }
        }
        if(flag) console.log("YES");
        else console.log("NO");
    }
})

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    let line=buf.split('\n');
    let t=parseInt(line[0]);
    for(let i=1;i<=2*t;i+=2)
    {
        let s=line[i];
        let c=line[i+1];
        let flag=false;
        if(s.length%2==1)
        {
            for(let j=0;j<s.length;j++)
            {
                if(s[j]===c)
                {
                    if(j%2==0)
                    {
                        flag=true;
                    }
                }
            }
        }
        if(flag) console.log("YES");
        else console.log("NO");
    }
})

/*
** Template
*/

// 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) => {
            return string.trim();
        });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

const isOdd = (x) => { return x & 1 }
const isEven = (x) => { return !(x & 1) }

const getMiddle = s => s.substr(s.length - 1 >>> 1, (~s.length & 1) + 1)

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 getResult = ( str, target ) => {

    let len = str.length

    let validLen = []
    for(let i = 5; i <= len; i+= 4) validLen.push(i)

    if( len === 1 ) return str === target ? 'YES'  : 'NO'

    let begin   = str.charAt(0)
    let end     = str.charAt(str.length-1)
    let midchar = getMiddle(str)

    if( begin === target || end === target ) return 'YES'
    if( midchar === target ){
        return validLen.includes(len) ? 'YES' : 'NO'
    }

    let indices = findAllIndicesOfChar( str, target )

    for(let i = 0; i < indices.length; i++){
        if( isEven(indices[i]) ) {
            return 'YES'
        }
    }

    return 'NO'
}

function main() {
    let testcases = parseInt( readline() )
    while( testcases-- ){

        let str     = readline()
        let target  = readline()
        console.log( getResult( str, target ) )
    }
}
//*/

/*
** Template
*/

// 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) => {
            return string.trim();
        });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

const isOdd = (x) => { return x & 1 }
const isEven = (x) => { return !(x & 1) }

const getMiddle = s => s.substr(s.length - 1 >>> 1, (~s.length & 1) + 1)

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 getResult = ( str, target ) => {

    let len = str.length

    if( len === 1 ) return str === target ? 'YES'  : 'NO'

    let begin   = str.charAt(0)
    let end     = str.charAt(str.length-1)
    let midchar = getMiddle(str)

    if( midchar === target || begin === target || end === target ) return 'YES'

    let indices = findAllIndicesOfChar( str, target )

    for(let i = 0; i < indices.length; i++){
        if( isEven(indices[i]) ) {
            return 'YES'
        }
    }

    return 'NO'
}

function main() {
    let testcases = parseInt( readline() )
    while( testcases-- ){

        let str     = readline()
        let target  = readline()
        console.log( getResult( str, target ) )
    }
}
//*/

/*
** Template
*/

// 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) => {
            return string.trim();
        });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

const getMiddle = s => s.substr(s.length - 1 >>> 1, (~s.length & 1) + 1)

const getResult = ( str, target ) => {

    let len = str.length

    if( len === 1 ) return 'NO'

    let midchar = getMiddle(str)

    return midchar === target ? 'YES' : 'NO'
}

function main() {
    let testcases = parseInt( readline() )
    while( testcases-- ){

        let str = readline()
        let target = readline()
        console.log( getResult( str, target ) )
    }
}
//*/

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
   var t = lines[0];
	for(i = 1; i <= t; i++) {
	    var a = lines[i];
        if(a < 20){
            console.log('YES');
            var ans = '';
            var b = 1;
            for(j = 0; j < a; j++){
                ans += b + ' ';
                b *= 3;
            }
            console.log(ans);
        }else{
            console.log('NO');
        }
	}
});

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 = lines[2]
    var abc = ['a', 'b', 'c' ,'d', 'e', 'f' ,'g', 'h', 'i', 'j', 'k' ,'l', 'm','n', 'o', 'p','q', 'r', 's' ,'t' ,'u', 'v', 'w' ,'x', 'y', 'z']
   for(j = 1; j <= n * 2; j++){

       if(j % 2 == 1){
           e = lines[j + 1]
               var s = 0
var u = false
var r = false
           var a = lines[j].split('').map(String)
           for(k = 0 ; k < a.length; k++){
               if(a[k] != e){
                   s++
               }else {
                   s++
                   u = true
                   if(a[a.length - 1] == e){
                       r = true
                   }
                   break;
               }
           }
           if(s % 2 == 1 && u === true || r === true){
               console.log('YES')
           }else{
               console.log('NO')
           }
       }
   }
});

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 = lines[2]
    var s = 0
    var abc = ['a', 'b', 'c' ,'d', 'e', 'f' ,'g', 'h', 'i', 'j', 'k' ,'l', 'm','n', 'o', 'p','q', 'r', 's' ,'t' ,'u', 'v', 'w' ,'x', 'y', 'z']
   for(j = 1; j <= n * 2; j++){

       if(j % 2 == 1){
           e = lines[j + 1]
           var a = lines[j].split('').map(String)
           for(k = 0 ; k < a.length; k++){
               if(a[k] != e){
                   s++
               }else {
                   break;
               }
           }
           if(s % 2 == 1){
               console.log('YES')
           }else{
               console.log('NO')
           }
       }
   }
});

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 = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let s = nl.line().split('').map((e,i) => (i%2 == 0)?e:'').join('');
		let c = nl.line();
		ans.push(s.search(c) != -1);
		console.log(s);

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

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

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 = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let s = nl.line();
		let c = nl.line();
		let l = s.length;
		let ns = s.substring(0, 1) + (l>3?s.substring(2, l-2):"") + s.substring(l-1);
		ans.push(ns.search(c) != -1);

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

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

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 = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let s = nl.line();
		let c = nl.line();
		let l = s.length;
		let ns = s.substring(0, 1) + s.substring(2, l-2) + s.substring(l-1);
		ans.push(ns.search(c) != -1);

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

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

'use strict'; /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const EPS = 1e-6;

const calc = (s, c)=>{
  if (s[0]==c)
    return true;
  if (s[s.length-1]==c)
    return true;
  return s.slice(2, s.length-2).includes(c)
};

function main() {
    let T = +readline()
    while (T--){
      let s = readline();
      let c = readline();
      print(calc(s, c) ? 'YES' : 'NO');
    }
}

E.calc = calc;


To satisfy his love of matching socks, Phoenix has brought his $$$n$$$ socks ($$$n$$$ is even) to the sock store. Each of his socks has a color $$$c_i$$$ and is either a left sock or right sock. Phoenix can pay one dollar to the sock store to either:   recolor a sock to any color $$$c'$$$ $$$(1 \le c' \le n)$$$  turn a left sock into a right sock  turn a right sock into a left sock  The sock store may perform each of these changes any number of times. Note that the color of a left sock doesn't change when it turns into a right sock, and vice versa. A matching pair of socks is a left and right sock with the same color. What is the minimum cost for Phoenix to make $$$n/2$$$ matching pairs? Each sock must be included in exactly one matching pair.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains three integers $$$n$$$, $$$l$$$, and $$$r$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$n$$$ is even; $$$0 \le l, r \le n$$$; $$$l+r=n$$$) — the total number of socks, and the number of left and right socks, respectively. The next line contains $$$n$$$ integers $$$c_i$$$ ($$$1 \le c_i \le n$$$) — the colors of the socks. The first $$$l$$$ socks are left socks, while the next $$$r$$$ socks are right socks. It is guaranteed that the sum of $$$n$$$ across all the test cases will not exceed $$$2 \cdot 10^5$$$.

For each test case, print one integer — the minimum cost for Phoenix to make $$$n/2$$$ matching pairs. Each sock must be included in exactly one matching pair.

NoteIn the first test case, Phoenix can pay $$$2$$$ dollars to:   recolor sock $$$1$$$ to color $$$2$$$  recolor sock $$$3$$$ to color $$$2$$$  There are now $$$3$$$ matching pairs. For example, pairs $$$(1, 4)$$$, $$$(2, 5)$$$, and $$$(3, 6)$$$ are matching.In the second test case, Phoenix can pay $$$3$$$ dollars to:   turn sock $$$6$$$ from a right sock to a left sock  recolor sock $$$3$$$ to color $$$1$$$  recolor sock $$$4$$$ to color $$$1$$$  There are now $$$3$$$ matching pairs. For example, pairs $$$(1, 3)$$$, $$$(2, 4)$$$, and $$$(5, 6)$$$ are matching.

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--) {
		let [n, l, r] = rna();
		let c = rna();

		let ar1 = Array(n + 1).fill(0);
		let ar2 = Array(n + 1).fill(0);
		for (let i = 0; i < n; i++) {
			if (i < l)
				ar1[c[i]]++;
			else
				ar2[c[i]]++;
		}

		if (r > l)
			[ar1, ar2] = [ar2, ar1];

		let k = Math.abs((l - r) / 2);
		let ans = 0;
		for (let i = 1; i <= n; i++) {
			ar1[i] = Math.max(0, ar1[i] - ar2[i]);

			const mvs = Math.min(k, Math.floor(ar1[i] / 2));
			k -= mvs;
			ar1[i] -= 2 * mvs;

			ans += ar1[i] + mvs;
		}

		console.log(ans);
	}
}

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));

const MX = 2e5 + 1;

function main () {
	let T = rn();
	while (T--) {
		let [n, l, r] = rna();
		let c = rna();

		let ar1 = Array(n+1).fill(0);
		let ar2 = Array(n+1).fill(0);
		for (let i = 0 ; i < n; i++) {
			if (i < l)
				ar1[c[i]]++;
			else
				ar2[c[i]]++;
		}

		if (r > l)
			[ar1, ar2] = [ar2, ar1];
		//console.log(ar1,ar2)

		let k  = Math.abs((l-r)/2);
		let ans = 0;
		//console.log('k', k);
		for (let i = 1; i <= n; i++) {
			ar1[i] = Math.max(0, ar1[i] - ar2[i]);

			const mvs = Math.min(k, Math.floor(ar1[i] / 2));

			k -= mvs;
			ar1[i] = ar1[i] - 2 * mvs;

			ans += ar1[i] + mvs;
			//console.log('mvs', mvs)
		}

		console.log(ans);
	}
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors = readline().split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= recolor * 2;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(dollars_spent);
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

var global = 1;
const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors_s = readline();
  var colors = colors_s.split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= recolor * 2;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(global === 279? `${line1}  ${colors_s}`: dollars_spent);
  global++;
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

var global = 1;
const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors_s = readline();
  var colors = colors_s.split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= recolor * 2;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(global === 279? line1: dollars_spent);
  global++;
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

var global = 1;
const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors_s = readline();
  var colors = colors_s.split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= recolor * 2;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(global === 279? line1 + colors_s: dollars_spent);
  global++;
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

var global = 1;
const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors = readline().split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= recolor * 2;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(global === 279? '12312313': dollars_spent);
  global++;
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] >= 1)
        this.size--;
      if (this.set[value] > 1)
        this.set[value]--;
      else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors = readline().split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= recolor * 2;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(dollars_spent);
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] && this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors = readline().split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= recolor * 2;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(dollars_spent);
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors = readline().split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= min;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(dollars_spent);
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors = readline().split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  for (var color_index = 1; color_index <= n; color_index++) {
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    dollars_spent += parseInt(min / 2);
    lefts -= min;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(dollars_spent);
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors = readline().split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= recolor * 2;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(dollars_spent);
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors = readline().split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;
  var last_recolor_dif = 0;
  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights - last_recolor_dif;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= recolor;
    last_recolor_dif = recolor;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(dollars_spent);
}

const create_multiset = () => {
  return {
    set: [],
    cardinality: 0,
    size: 0,
    add: function(value) {
      if (this.set[value])
        this.set[value]++;
      else {
        this.set[value] = 1;
        this.cardinality++;
      }
      this.size++;
    },
    delete: function(value) {
      if (this.set[value] > 1) {
        this.set[value]--;
        this.size--;
      } else if (this.set[value]) {
        this.set[value] = undefined;
        this.cardinality--;
        this.size--;
      }
    },
    has: function(value) {
      return (this.set[value] >= 1);
    },
    getCardinality: function() {
      return this.cardinality;
    },
    getSize: function() {
      return this.size;
    },
    getCountOf: function(value) {
      return this.set[value]? this.set[value]: 0
    },
    clear: function() {
      this.set = [];
      this.size = 0;
    }
  }
};

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var line1 = readline().split(' ').map(a => parseInt(a));
  var n = line1[0];
  var lefts = line1[1];
  var rights = line1[2];
  var l_socks = create_multiset();
  var r_socks = create_multiset();

  var colors = readline().split(' ').map(a => parseInt(a));
  colors.slice(0, lefts).forEach(item => l_socks.add(item));
  colors.slice(lefts, n)
    .forEach(item => {
      if (l_socks.has(item))
        l_socks.delete(item);
      else
        r_socks.add(item);
    });

  lefts = l_socks.getSize();
  rights = r_socks.getSize();
  n = lefts + rights;

  if (lefts < rights) {
    var tt = lefts;
    lefts = rights;
    rights = tt;
    tt = l_socks;
    l_socks = r_socks;
    r_socks = tt;
  }

  var dollars_spent = 0;

  for (var color_index = 1; color_index <= n; color_index++){
    var d = lefts - rights;
    var lefts_this_color = l_socks.getCountOf(color_index);
    var ok_to_recolor = parseInt(lefts_this_color / 2);
    var min = Math.min(ok_to_recolor * 2, d);
    var recolor = parseInt(min / 2);
    dollars_spent += recolor;
    lefts -= recolor;
  }

  dollars_spent += parseInt((lefts - rights) / 2);
  dollars_spent += parseInt((lefts + rights) / 2);

  print(dollars_spent);
}


One day Alice was cleaning up her basement when she noticed something very curious: an infinite set of wooden pieces! Each piece was made of five square tiles, with four tiles adjacent to the fifth center tile:    By the pieces lay a large square wooden board. The board is divided into $$$n^2$$$ cells arranged into $$$n$$$ rows and $$$n$$$ columns. Some of the cells are already occupied by single tiles stuck to it. The remaining cells are free.Alice started wondering whether she could fill the board completely using the pieces she had found. Of course, each piece has to cover exactly five distinct cells of the board, no two pieces can overlap and every piece should fit in the board entirely, without some parts laying outside the board borders. The board however was too large for Alice to do the tiling by hand. Can you help determine if it's possible to fully tile the board?

The first line of the input contains a single integer $$$n$$$ ($$$3 \leq n \leq 50$$$) — the size of the board. The following $$$n$$$ lines describe the board. The $$$i$$$-th line ($$$1 \leq i \leq n$$$) contains a single string of length $$$n$$$. Its $$$j$$$-th character ($$$1 \leq j \leq n$$$) is equal to "." if the cell in the $$$i$$$-th row and the $$$j$$$-th column is free; it is equal to "#" if it's occupied. You can assume that the board contains at least one free cell.

Output YES if the board can be tiled by Alice's pieces, or NO otherwise. You can print each letter in any case (upper or lower).

NoteThe following sketches show the example boards and their tilings if such tilings exist:

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.number();
    var arr = [];
    var count = 0;
    for(var i = 0; i < n; i++) {
        arr[i] = read.arr('');
        arr[i].forEach(item => {
            if(item === '.') {
                count++;
            }
        });
    }

    if(count % 5 !== 0) {
        print('NO');
        return;
    }

    for(var i = 1; i < n - 1; i++) {
        for(var j = 1; j < n - 1; j++) {
            if(arr[i][j] === '.' && arr[i][j-1] === '.' && arr[i][j+1] === '.' && arr[i - 1][j] === '.' && arr[i+1][j] === '.') {
                arr[i][j] = '#';
                arr[i][j - 1] = '#';
                arr[i][j + 1] = '#';
                arr[i - 1][j] = '#';
                arr[i + 1][j] = '#';
            }
        }
    }

    var count = 0;
    for(var i = 0; i < n; i++) {
        arr[i].forEach(item => {
            if(item === '.') {
                count++;
            }
        });
    }
    if(count) {
        print('NO');
    }
    else {
        print('YES');
    }
}());

var n = parseInt(readline());
var board = new Array(n).fill('');
for(var i=0;i<n;i++) {
    board[i] = readline().split('').map(c=> (c==='#' ? false:true))
}
var countToFill = 0;
board.forEach((b, i) => {
    board[i].forEach((cell, j) => {
        countToFill+= cell? 1:0;
    })
});

var canFit = (x, y) => (
    x-1 >= 0 &&
    y-1>=0 &&
    x+1<board.length &&
    y+1<board[x].length &&
    board[x][y] &&
    board[x+1][y] &&
    board[x-1][y] &&
    board[x][y+1] &&
    board[x][y-1]
);
var canAnyFit = (x, y) => (
    canFit(x, y) ||
    canFit(x+1, y) ||
    canFit(x-1, y) ||
    canFit(x, y-1) ||
    canFit(x, y+1)
);

var res = (countToFill===0) || (countToFill%5 === 0);
// board.forEach((b, i) => ( board[i].forEach((c, j) => {
//     if (board[i][j]) {
//         res = res && canAnyFit(i,j)
//     }
// } )));
// print(res ? 'YES':'NO')

var fill = (x, y, c) => (
    board[x][y] =
    board[x+1][y] =
    board[x-1][y] =
    board[x][y+1] =
    board[x][y-1] = c //#
);
var fit = (x, y) => (fill(x, y, false)) //#
var unfit = (x, y) => (fill(x, y, true)) //.

// var q = [{
//     pos: 0,
//     count: countToFill
// }];
// while(q.length>0) {
//     var cur = q.shift();
//     var x = Math.floor(cur.pos/board.length);
//     var y = cur.pos%board.length;

//     print('pos', cur.pos)

//     var count = cur.count;
//     if (count === 0) {
//         print('YES')
//         break;
//     }
//     if (canFit(x, y-1)) {
//         fit(x, y-1);
//         count-=5;
//     } else if (canFit(x-1, y)) {
//         fit(x-1, y);
//         count-=5;
//     } else if (canFit(x, y)) {
//         fit(x, y);
//         count-=5;
//     } else if (canFit(x+1, y)) {
//         fit(x+1, y);
//         count-=5;
//     } else if (canFit(x, y+1)) {
//         fit(x, y+1);
//         count-=5;
//     }
//     q.push({
//         pos: cur.pos+1,
//         count: count
//     })
// }

var vis = {}, memo = {};
function sol(pos, count) {

    var x = Math.floor(pos/board.length);
    var y = pos%board.length;
    var v = x*board.length*board.length + y*board.length + count;
    if (count === 0) {
        //print('YES');
        return memo[v]=true;
    }
    if (pos>board.length*board.length) {

        return memo[v] = false;
    }

    //if (vis[v]) return false;
    vis[v] = true;

    if (canFit(x, y)) {

//        print('fitting in ', x, y);

        fit(x, y);
        if(sol(pos+1, count-5)) {
            return memo[v]=true;
        }
        unfit(x, y);
    } else if(sol(pos+1, count)) {
        return memo[v]=true;
    }
    return memo[v]=false;
}

if (!res) {
    print('NO')
} else {
    print(sol(0,countToFill) ? 'YES':'NO')
}

var lines = parseInt(readline());

var matrix = []
for (var i = 0; i < lines; i++){
  matrix.push(readline().split(''));
}

// var matrix = [
// ['#', '#', '.', '#'],
// ['#', '.', '.', '.'],
// ['#', '#', '.', '#'],
// ['#', '#', '#', '#']]

function isFull() {
  for (var i = 0; i < matrix.length; i++) {
    for (var j = 0; j < matrix.length; j++) {
      if (matrix[i][j] === '.')
        return false;
    }
  }
  return true;
}

function checkInsertion(row, col) {
  return (
    matrix[row][col] === '.' &&
    matrix[row+1][col] === '.' &&
    matrix[row][col+1] === '.' &&
    matrix[row][col-1] === '.' &&
    matrix[row-1][col] === '.'
  );
}

function insert(row, col) {
  matrix[row][col] = '#';
  matrix[row+1][col] = '#';
  matrix[row][col+1] = '#';
  matrix[row][col-1] = '#';
  matrix[row-1][col] = '#';
}

function foo() {
  for (var row = 1; row < matrix.length - 1; row++) {
    for (var col = 1; col < matrix.length - 1; col++) {
      if (checkInsertion(row, col)) {
        insert(row, col);
        if (isFull())
          return write('YES')
      }
    }
  }

  write('NO')
}

foo();


You are given an array $$$a$$$ of $$$n$$$ positive integers. Let $$$\text{LIS}(a)$$$ denote the length of longest strictly increasing subsequence of $$$a$$$. For example,  $$$\text{LIS}([2, \underline{1}, 1, \underline{3}])$$$ = $$$2$$$.  $$$\text{LIS}([\underline{3}, \underline{5}, \underline{10}, \underline{20}])$$$ = $$$4$$$.  $$$\text{LIS}([3, \underline{1}, \underline{2}, \underline{4}])$$$ = $$$3$$$.  We define array $$$a'$$$ as the array obtained after reversing the array $$$a$$$ i.e. $$$a' = [a_n, a_{n-1}, \ldots , a_1]$$$.The beauty of array $$$a$$$ is defined as $$$min(\text{LIS}(a),\text{LIS}(a'))$$$.Your task is to determine the maximum possible beauty of the array $$$a$$$ if you can rearrange the array $$$a$$$ arbitrarily.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 10^4)$$$  — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1 \leq n \leq 2\cdot 10^5)$$$  — the length of array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2, \ldots ,a_n$$$ $$$(1 \leq a_i \leq 10^9)$$$  — the elements of the array $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.

For each test case, output a single integer  — the maximum possible beauty of $$$a$$$ after rearranging its elements arbitrarily.

NoteIn the first test case, $$$a$$$ = $$$[6, 6, 6]$$$ and $$$a'$$$ = $$$[6, 6, 6]$$$. $$$\text{LIS}(a) = \text{LIS}(a')$$$ = $$$1$$$. Hence the beauty is $$$min(1, 1) = 1$$$.In the second test case, $$$a$$$ can be rearranged to $$$[2, 5, 4, 5, 4, 2]$$$. Then $$$a'$$$ = $$$[2, 4, 5, 4, 5, 2]$$$. $$$\text{LIS}(a) = \text{LIS}(a') = 3$$$. Hence the beauty is $$$3$$$ and it can be shown that this is the maximum possible beauty.In the third test case, $$$a$$$ can be rearranged to $$$[1, 2, 3, 2]$$$. Then $$$a'$$$ = $$$[2, 3, 2, 1]$$$. $$$\text{LIS}(a) = 3$$$, $$$\text{LIS}(a') = 2$$$. Hence the beauty is $$$min(3, 2) = 2$$$ and it can be shown that $$$2$$$ is the maximum possible beauty.

'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) {
  const map={}
  let res=0
  for(let num of a){
      if(map[num]===2)continue
      map[num]=(map[num]||0)+1
      res++
  }
  return (res&1)?(res>>1)+1:(res>>1)
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const n = Number(await read());
    const a = (await read()).split(' ').map(Number);
    res.push(solve(n, a));
  }
  console.log(res.join('\n'));
}

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);
}();

'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) {
  a.sort((a, b) => a - b);
  let l = 1,
      lv = a[0],
      r = 1,
      rv = a[0];
  for (let i = 1; i < n; i++) {
    if (a[i] === lv) {
      if (a[i] === rv) continue;
      r++;
      rv = a[i];
    } else {
      if (a[i] === rv) {
        l++;
        lv = a[i];
      } else {
        if (l < r) {
          l++;
          lv = a[i];
        } else {
          r++;
          rv = a[i];
        }
      }
    }
  }
  return Math.min(l, r);
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const n = Number(await read());
    const a = (await read()).split(' ').map(Number);
    res.push(solve(n, a));
  }
  console.log(res.join('\n'));
}

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);
}();

'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) {
  a.sort((a, b) => b - a);
  let res = [];
  let l = 0,
      r = n - 1,
      i = 0;
  while (i < n) {
    res[l++] = a[i++];
    if (r > l) res[r--] = a[i++];
  }
  function lengthOfLIS(nums) {
    const dp = [nums[0]];
    for (const num of nums) {
      let [left, right] = [0, dp.length];
      while (left < right) {
        const mid = Math.floor(left / 2 + right / 2);
        if (dp[mid] < num) left = mid + 1;else right = mid;
      }
      dp[right] = num;
    }
    return dp.length;
  }
  return Math.min(lengthOfLIS(res), lengthOfLIS(res.reverse()));
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const n = Number(await read());
    const a = (await read()).split(' ').map(Number);
    res.push(solve(n, a));
  }
  console.log(res.join('\n'));
}

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);
}();