Madoka finally found the administrator password for her computer. Her father is a well-known popularizer of mathematics, so the password is the answer to the following problem.Find the maximum decimal number without zeroes and with no equal digits in a row, such that the sum of its digits is $$$n$$$.Madoka is too tired of math to solve it herself, so help her to solve this problem!

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Description of the test cases follows. The only line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 1000$$$) — the required sum of the digits.

For each test case print the maximum number you can obtain.

NoteThe only numbers with the sum of digits equal to $$$2$$$ without zeros are $$$2$$$ and $$$11$$$. But the last one has two ones in a row, so it's not valid. That's why the answer is $$$2$$$.The only numbers with the sum of digits equal to $$$3$$$ without zeros are $$$111$$$, $$$12$$$, $$$21$$$, and $$$3$$$. The first one has $$$2$$$ ones in a row, so it's not valid. So the maximum valid number is $$$21$$$.The only numbers with the sum of digits equals to $$$4$$$ without zeros are $$$1111$$$, $$$211$$$, $$$121$$$, $$$112$$$, $$$13$$$, $$$31$$$, $$$22$$$, and $$$4$$$. Numbers $$$1111$$$, $$$211$$$, $$$112$$$, $$$22$$$ aren't valid, because they have some identical digits in a row. So the maximum valid number is $$$121$$$.

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

    for(j = 1; j <= n; j++){
        a = lines[j]
        s = 0
        answer = ''
            if(a % 3 == 1){
                while(s < a){
                    s += 1
                    answer += 1
                    if(s + 2 < a){
                        s += 2
                        answer += 2
                    }
                }
                console.log(answer)
            }else{
                while(s < a){
                    s += 2
                    answer += 2
                    if(s + 1 <= a){
                        s += 1
                        answer += 1
                    }
                }
                console.log(answer)
            }
    }

});

'use strict';

let cin = '';
let current_line = 0;

function     next() { return cin[current_line++]; }
function  nextInt() { return parseInt(next()); }
function nextList() { return next().split(' ').map(s => parseInt(s)); }
function   print(x) { process.stdout.write(x); }
function println(x) { console.log(x); }

const digit = "012";

function solve(n) {
    let ans = "";
    let x = (n%3 == 1) ? 1 : 2;
    while (n > 0) {
        n -= x; ans += digit[x]; x = 3-x; }
    return ans; }

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', line => { cin += line; });
process.stdin.on('end', _ => {
    cin = cin.trim().split('\n').map(line => { return line.trim(); });
    for (let t = nextInt(); t > 0; --t)
        println(solve(nextInt())); });

'use strict';

let cin = '';
let current_line = 0;

function     next() { return cin[current_line++]; }
function  nextInt() { return parseInt(next()); }
function nextList() { return next().split(' ').map(s => parseInt(s)); }
function   print(x) { process.stdout.write(x); }
function println(x) { console.log(x); }

const digit = "012";

function solve(n) {
    const r = n%3;
    const m = n-2;
    let ans = "";
    let sum = 0;
    if (r == 1) {
        ans += "1";
        sum = 1; }
    while (sum < m) {
        ans += "21";
        sum += 3; }
    if (sum < n)
        ans += digit[n-sum];
    return ans; }

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', line => { cin += line; });
process.stdin.on('end', _ => {
    cin = cin.trim().split('\n').map(line => { return line.trim(); });
    for (let t = nextInt(); t > 0; --t)
        println(solve(nextInt())); });

'use strict';

let cin = '';
let current_line = 0;

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', line => { cin += line; });
process.stdin.on('end', _ => {
    cin = cin.trim().split('\n').map(line => { return line.trim(); });
    main(); });

function     next() { return cin[current_line++]; }
function  nextInt() { return parseInt(next()); }
function nextList() { return next().split(' ').map(s => parseInt(s)); }

function   print(x) { process.stdout.write(x); }
function println(x) { console.log(x); }

const digit = "012";

function solve(n) {
    const r = n%3;
    const m = n-2;
    let ans = "";
    let sum = 0;
    if (r == 1) {
        ans += "1";
        sum = 1; }
    while (sum < m) {
        ans += "21";
        sum += 3; }
    if (sum < n)
        ans += digit[n-sum];
    return ans; }

function main() {
    for (let t = nextInt(); t > 0; --t)
        println(solve(nextInt())); }

'use strict';

let cin = '';
let current_line = 0;

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', line => { cin += line; });
process.stdin.on('end', _ => {
    cin = cin.trim().split('\n').map(line => { return line.trim(); });
    main(); });

function     next() { return cin[current_line++]; }
function  nextInt() { return parseInt(next()); }
function nextList() { return next().split(' ').map(s => parseInt(s)); }

const digit = "012";

function solve(n) {
    let ans = "";
    let sum = 0;
    const r = n%3;
    if (r == 1) {
        ans += "1";
        sum = 1; }
    const m = n-2;
    while (sum < m) {
        ans += "21";
        sum += 3; }
    if (sum < n)
        ans += digit[n-sum];
    return ans; }

function main() {
    for (let t = nextInt(); t > 0; --t)
        console.log(solve(nextInt())); }

"use strict";

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

let inputStr = "";
let currentLne = 0;

process.stdin.on('data' , inputStdin =>{

	 inputStr += inputStdin;
})

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

main();
})

function readline(){
   return inputStr[currentLne++];
}

function main(){

    let t = parseInt(readline()) ;
    let c =0;
    while(c<t){
       let num =  parseInt(readline()) ;

            let s = "";
            let t ="21";
            let b =0;
            let d =0;
            let x =0;
            let k="";
            let l="";
            let m="";

            function gen21(total){
                let count =0;
                let add = "";
                while(count<total){
                    add +="21";
                    count++;
                }
                return add;
            }

            if(num%3 ==0){
                x = num/3;
                m = gen21(x);
                console.log(m);
            }
            if((num-1)%3 == 0 ){
               b = (num-1)/3;
               k = gen21(b);
               s = "1"+ k;
               console.log(s)
            }
            if((num+1)%3 == 0){
                d = (num+1)/3;
                l = gen21(d);
                l = l.split("")

                l.splice(-1,1);

               l = l.join("");
               console.log(l)
            }

        c++;
    }

}

//type input.txt | node code.js

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]);
    let a=[];
    for(let i=1;i<=1000;i++)
    {
        if(i&1) a.push(1);
        else a.push(2);
    }
    for(let _=1;_<=t;_++)
    {
        let n=parseInt(line[_]);
        let ans=0;
        let sum=0;
        let x=0;
        let str='';
        while(sum<n)
        {
            str+=a[x];
            sum+=a[x++];
        }
        if(sum==n) ans=str;
        sum=0;
        x=1;
        str='';
        while(sum<n)
        {
            str+=a[x];
            sum+=a[x++];
        }
        if(sum==n) ans=str;
        console.log(ans);
    }
})

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]);
    let a=[];
    for(let i=1;i<=1000;i++)
    {
        if(i&1) a.push(1);
        else a.push(2);
    }
    for(let _=1;_<=t;_++)
    {
        let n=parseInt(line[_]);
        // console.log(n);
        let ans=0;
        let sum=0;
        let x=0;
        let str='';
        while(sum<n)
        {
            str+=a[x];
            sum+=a[x++];
        }
        if(sum==n) ans=str;
        sum=0;
        x=1;
        str='';
        while(sum<n)
        {
            str+=a[x];
            sum+=a[x++];
        }
        if(sum==n) ans=str;
        console.log(ans);
    }
})

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

let num = -1;
const rows = [];
rl.on('line', line => {
    if (num < 0) {
        num = parseInt(line.trim());
    } else {
        rows.push(line.trim());
        if (rows.length === num) {
            dealInput(rows);
        }
    }
});
const dealInput = (rows) => {
    rows.forEach(item => {
        let m = item % 3;
        let n = parseInt(item / 3);
        let a = '1',
            b = '21';
        if (m === 1) {
            a = '1'
            b = '12'
        } else if (m === 2) {
            a = '2'
            b = '21'
        } else {
            a = ''
            b = '21'
        }
        console.log(setNum(n, b) + a);
    })
    rl.close();
};

function setNum(m, n) {
    if (m === 0) return ''
    let num = ''
    for (let i = 0; i < m; i++) {
        num += n
    }
    return num
}
rl.on('close', () => {
    process.exit(0);
});

let text = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', str => {
    if (str === '\r\n' || str === '\n') {
        process.stdin.emit('end');
    } else {
        text += str;
    }
});

process.stdin.on('end', () => {
    const input = text.trim().replace(/r/g, '').split('\n');
    const total = Number(input[0]);
    for (let i = 1; i <= total; i++) {
        solve(Number(input[i]));
    }

    process.exit();
});

function solve(number) {
    const mod = number % 3;
    const group = (number - mod) / 3;
    let result = '';
    if (mod < 2) {
        mod && (result = '1');
        result += '21'.repeat(group);
    } else {
        result = '2';
        result += '12'.repeat(group);
    }
    console.log(result);
}

function solve(arr) {
  let data = [...arr];
  data.shift();
  data = data.map((num) => parseInt(num));
  data.forEach((num) => {
    if (num === 1) {
      console.log(1);
    } else if (num === 2) {
      console.log(2);
    } else if (num === 3) {
      console.log(21);
    } else {
      const a = num % 3;
      const b = parseInt(num / 3);
      let str = "";
      for (let i = 0; i < b; i++) {
        str += "21";
      }
      if (a === 1) {
        console.log(`1${str}`);
      } else if (a === 2) {
        console.log(`${str}2`);
      } else {
        console.log(str);
      }
    }
  });
}
let text = "";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
process.stdin.on("data", (t) => {
  if (t === "\r\n" || t === "\n") {
    process.stdin.emit("end");
  } else {
    text += t;
  }
});
process.stdin.on("end", () => {
  const input = text.trim().replace(/\r/g, "").split("\n");
  solve(input);
  process.exit();
});

function repeat(num, t){
    var ans = '';
    if(t === 0){

    }
    if(t == 1){
        ans += 1;
    }
    for(j = 0; j < num; j++){
        ans += 21;
    }
    if(t == 2){
        ans += 2;
    }
    console.log(ans);
}

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];
    for(i = 1; i <= n; i++){
        var k = lines[i];
        var a = Math.floor(k / 3);
        if(k % 3 === 0){
            repeat(a, 0);
        }else if(k % 3 == 1){
            repeat(a, 1);
        }else{
            repeat(a, 2);
        }
    }
});

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 n = parseInt(ls[i++]);
        let sum = 0;
        let num = n % 3 == 1 ? 1 : 2;
        let ans = '';
        while (sum < n){
            ans += num;
            sum += num;
            num = 3 - num;
        }
        console.log(ans);
    }
}

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

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

  main();
});

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

function main() {
  const testCases = readline();

  for (let i = 0; i < testCases; i++) {
    let n = Number(readline());

    let next = 2;
    if (n % 3 === 1) {
      next = 1;
    }

    let length = Math.ceil(n / 3) * 2;
    if (n % 3 !== 0) {
      length--;
    }

    let result = "";
    for (let i = 0; i < length; i++) {
      // result *= 10;
      // result += next;
      result = result + next;
      if (next === 2) {
        next = 1;
      } else {
        next = 2;
      }
    }

    console.log(result);
  }
}

'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 res = '';
        if (n % 3 === 1) {
            output('12'.repeat(Math.floor(n / 3)) + '1');
        } else if (n % 3 === 2) {
            let base = '21'.repeat(Math.floor(n / 3))
            output(base + '2');
        } else {
            output('21'.repeat(n/3));
        }
    }
}

'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 = (n)=>{
  let res = '';
  let start = 2;
  let m = n
  debugger
  while (m>0){
    res += start;
    m -= start;
    start = start==1 ? 2 : 1;
  }
  if (m==0)
    return res;
  res = '';
  start = 1;
  m = n;
  while (m>0){
    res += start;
    m -= start;
    start = start==1 ? 2 : 1;
  }
  return res;
};

function main() {
    let T = +readline();
    while (T--){
      let n = +readline();
      print(calc(n));
    }
}

E.calc = calc;

//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 N = nextInt();
		var one = N % 2;
		var two = Math.floor(N / 2);
		while(Math.abs(two - one) > 1){
			two--;
			one += 2;
		}

		var output = [];
		if(one > two){
			output.push(1);
			one--;
		}
		while(one > 0 && two > 0){
			output.push(2);
			output.push(1);
			one--;
			two--;
		}
		if(two > 0){
			output.push(2);
		}
		myout(myconv(output, 0));
	}
}

function solve() {
   const n = Number(read());
   const div3 = Math.floor(n / 3);
   const mod3 = n % 3;
   let ans = '21'.repeat(div3);
   if (mod3 === 1) {
      ans = '1' + ans;
   }
   if (mod3 === 2) {
      ans = ans + '2';
   }
   write(ans);
}

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

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1n;
   while(curN) {
      if (curN & 1n) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1n;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

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

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

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;

   var needWriteFile = false;

   var writeResult = '';
   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();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

//const { readline, print } = require('@ip-algorithmics/codeforces-io');

function readLineNumbers() {
  return readline().split(' ').map(x => parseInt(x))
}

function getSequenceToSum(sum, start) {
  var last = start;
  var sumOfDigits = start;
  var finalNumber = '' + start;

  while (sumOfDigits < sum) {
    var digit = last === 1 ? 2 : 1
    sumOfDigits += digit;
    finalNumber += digit;
    last = digit;
  }

  return [sumOfDigits, finalNumber];
}

var n = readLineNumbers()[0]

while (n--) {
  var sum = readLineNumbers()[0];

  var a = getSequenceToSum(sum, 1)
  var b = getSequenceToSum(sum, 2)

  if (a[0] === sum && b[0] === sum) {
    print ( a[0] > b[0] ? a[1] : b[1]  )
  } else {
    print(a[0] === sum ? a[1] : b[1]);
  }
}

var tests = parseInt(readline());
    var n;

    for (var t=0; t < tests; t++) {
        n = parseInt(readline());
		var ans = [];

		var num = 2;
		if (n % 3 == 1) {
			num = 1;
		}
		while (n > 0) {
			ans.push(num);
			n -= num;
			if (num == 1) {
				num = 2;
			} else {
				num = 1;
			}
		}
		print(ans.join(''));
    }

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var k = lines[0];
    var s = ''
    var n = 0
    var g = false
    for(j = 1; j <= k; j++){
        var a = lines[j]
        while(n <= a){
            if(g === false){
            s += '1'
            n += 1
            a -= 1

            if(n + 1 >= a){
                s += '2'
            n += 2
            a -= 2
            }
            } else if(g === true){
               s += '2'
            n += 2
            a -= 2
            if(n + 2 >= a){
            s += '1'
            n += 1
            a -= 1
}
            }
        }
            console.log(s)

    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var k = lines[0];
    var s = ''
    var n = 0
    var g = false
    for(j = 1; j <= k; j++){
        var a = lines[j]
        while(n <= a){
            if(g === false){
            s += '1'
            n += 1
            a -= 1

            if(n + 1 != a){
                s += '2'
            n += 2
            a -= 2
            }
            } else if(g === true){
               s += '2'
            n += 2
            a -= 2
                        if(n + 2 != a){
s += '1'
            n += 1
            a -= 1
}
            }
        }
            console.log(s)

    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var k = lines[0];
    var s = ''
    var n = 0
    var g = false
    for(j = 1; j <= k; j++){
        var a = lines[j]
        while(n <= a){
            if(g === false){
            s += '1'
            n += 1
            a -= 1

            if(n + 2 == a){
                s += '2'
            n += 2
            a -= 2
            }
            } else if(g === true){
               s += '2'
            n += 2
            a -= 2
                        if(n + 1 == a){
s += '1'
            n += 1
            a -= 1
}
            }
        }
            console.log(s)

    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var k = lines[0];
    var s = ''
    var n = 0
    for(j = 1; j <= k; j++){
        var a = lines[j]
        while(n <= k)
        if(a % 2 ==1 ){
            s += '1'
            n += 1
            a -= 1
        }else if(a % 2 === 0){
            s+='2'
            n += 2
            a -= 2
        }
            console.log(s)

    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var k = lines[0];
    var s = ''
    var n = 0
    for(j = 1; j <= k; j++){
        var a = lines[j]
        while(n <= k)
        if(a % 2 ==1 ){
            s += '1'
            n += 1
        }else if(a % 2 === 0){
            s+='2'
            n += 2
        }
            console.log(s)

    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var k = lines[0];
    var s = ''
    var n = 0
    for(j = 1; j <= k; j++){
        var a = lines[j]
        while(n <= k)
        if(a % 2 ==1 ){
            s += '1'
            n += 1
        }else if(a % 2 === 0){
            s+='2'
            n += 2
        }
    }
    console.log(s)
});

'use strict';

let cin = '';
let current_line = 0;

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', line => { cin += line; });
process.stdin.on('end', _ => {
    cin = cin.trim().split('\n').map(line => { return line.trim(); });
    main(); });

function     next() { return cin[current_line++]; }
function  nextInt() { return parseInt(next()); }
function nextList() { return next().split(' ').map(s => parseInt(s)); }

function solve(n) {
    let ans = "";
    let sum = 0;
    if (n%3 == 2) {
        ans += "2";
        sum = 2; }
    const m = n-2
    while (sum < m) {
        ans += "12";
        sum += 3; }
    if (sum < n)
        ans += "1";
    return ans; }

function main() {
    for (let t = nextInt(); t > 0; --t)
        console.log(solve(nextInt())); }

'use strict';

let cin = '';
let current_line = 0;

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', line => { cin += line; });
process.stdin.on('end', _ => {
    cin = cin.trim().split('\n').map(line => { return line.trim(); });
    main(); });

function     next() { return cin[current_line++]; }
function  nextInt() { return parseInt(next()); }
function nextList() { return next().split(' ').map(s => parseInt(s)); }

function solve(n) {
    let ans = "";
    if (n%3 == 2)
        ans += "2";
    const m = n-1;
    while (ans.length < m)
        ans += "12";
    if (ans.length < n)
        ans += "1";
    return ans; }

function main() {
    for (let t = nextInt(); t > 0; --t)
        console.log(solve(nextInt())); }

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

let num = -1;
const rows = [];
rl.on('line', line => {
    if (num < 0) {
        num = parseInt(line.trim());
    } else {
        rows.push(line.trim());
        if (rows.length === num) {
            dealInput(rows);
        }
    }
});
const dealInput = (rows) => {
    rows.forEach(item => {
        if(item <= 2) {
            console.log(item);
        }else {
            console.log(getNum(item));
        }
    })
    rl.close();
};
function getNum(num) {
    let s = 0
    if(num%2 ===1) {
        s = 2
    } else {
        s = 1
    }
    return setS(s,num)
}
function setS(s,num) {
    let ss = String(s)
    for(let i = s; i < num;) {
        if(ss[ss.length-1] == 1) {
            ss += '2'
            i += 2
        } else {
            ss += '1'
            i += 1
        }
    }
    return ss
}
rl.on('close', () => {
    process.exit(0);
});

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 testCases = readline();

  for (let i = 0; i < testCases; i++) {
    let n = Number(readline());

    let next = 2;
    if (n % 3 === 1) {
      next = 1;
    }

    let length = Math.ceil(n / 3) * 2;
    if (n % 3 !== 0) {
      length--;
    }

    let result = 0;
    for (let i = 0; i < length; i++) {
      result *= 10;
      result += next;
      if (next === 2) {
        next = 1;
      } else {
        next = 2;
      }
    }

    console.log(result);
  }
}

function readLineNumbers() {
  return readline().split(' ').map(x => parseInt(x))
}

function getSequenceToSum(sum, start) {
  var last = start;
  var sumOfDigits = start;
  var finalNumber = start;

  while (sumOfDigits < sum) {
    var digit = last === 1 ? 2 : 1
    sumOfDigits += digit;
    finalNumber = finalNumber * 10 + digit;
    last = digit;
  }

  return [sumOfDigits, finalNumber];
}

var n = readLineNumbers()[0]

while (n--) {
  var sum = readLineNumbers()[0];

  var a = getSequenceToSum(sum, 1)
  var b = getSequenceToSum(sum, 2)

  if (a[0] === sum && b[0] === sum) {
    print ( a[0] > b[0] ? a[1] : b[1]  )
  } else {
    print(a[0] === sum ? a[1] : b[1]);
  }
}

function readLineNumbers() {
  return readline().split(' ').map(x => parseInt(x))
}

function getSequenceToSum(sum, start) {
  var last = start;
  var sumOfDigits = start;
  var finalNumber = start;

  while (sumOfDigits < sum) {
    var digit = last === 1 ? 2 : 1
    sumOfDigits += digit;
    finalNumber = finalNumber * 10 + digit;
    last = digit;
  }

  return sumOfDigits === sum ? finalNumber : -1;
}

var n = readLineNumbers()[0]

while (n--) {
  var sum = readLineNumbers()[0];

  var a = getSequenceToSum(sum, 1)
  var b = getSequenceToSum(sum, 2)
  print(a === -1 ? b : a);
}


You are an upcoming movie director, and you have just released your first movie. You have also launched a simple review site with two buttons to press — upvote and downvote.However, the site is not so simple on the inside. There are two servers, each with its separate counts for the upvotes and the downvotes.$$$n$$$ reviewers enter the site one by one. Each reviewer is one of the following types:   type $$$1$$$: a reviewer has watched the movie, and they like it — they press the upvote button;  type $$$2$$$: a reviewer has watched the movie, and they dislike it — they press the downvote button;  type $$$3$$$: a reviewer hasn't watched the movie — they look at the current number of upvotes and downvotes of the movie on the server they are in and decide what button to press. If there are more downvotes than upvotes, then a reviewer downvotes the movie. Otherwise, they upvote the movie. Each reviewer votes on the movie exactly once.Since you have two servers, you can actually manipulate the votes so that your movie gets as many upvotes as possible. When a reviewer enters a site, you know their type, and you can send them either to the first server or to the second one.What is the maximum total number of upvotes you can gather over both servers if you decide which server to send each reviewer to?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains a single integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of reviewers. The second line of each testcase contains $$$n$$$ integers $$$r_1, r_2, \dots, r_n$$$ ($$$1 \le r_i \le 3$$$) — the types of the reviewers in the same order they enter the site.

For each testcase print a single integer — the maximum total number of upvotes you can gather over both servers if you decide which server to send each reviewer to.

NoteIn the first testcase of the example you can send the only reviewer to either of the servers — they'll downvote anyway. The movie won't receive any upvotes.In the second testcase of the example you can send all reviewers to the first server:   the first reviewer upvotes;  the second reviewer downvotes;  the last reviewer sees that the number of downvotes is not greater than the number of upvotes — upvote themselves. There are two upvotes in total. Alternatevely, you can send the first and the second reviewers to the first server and the last reviewer — to the second server:   the first reviewer upvotes on the first server;  the second reviewer downvotes on the first server;  the last reviewer sees no upvotes or downvotes on the second server — upvote themselves.

var t = readline();
    for(var i = 0 ; i < t ; i++){
        var n =readline(),
            reviewers = readline().split(' ') , counter = 0;
            for(var j = 0 ; j < n ; j++){
                if(reviewers[j] == 1 || reviewers[j] == 3){
                    counter++;
                }
            }
            print(counter);
    }

'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++];
}

var maxN = 2 * 1e5 + 10
var mod = BigInt(1e9 + 7)

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [n, m] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    })
    var l1 = 0
    var d1 = 0
    var l2 = 0
    var d2 = 0

    for (let i = 0; i < n; i++) {
      if (a[i] === 1 || a[i] ===3) {
        l1 += 1
        continue
      }
    }

    console.log(l1 + l2)

  })
}

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(var j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number);
            var upvote = 0;
            var downvote = 0;
            var undecided = 0;
            for(var l = 0; l < e; l++){
                if(k[l] == 1){
                    upvote++;
                }else if(k[l] == 2){
                    downvote++;
                }else{
                    undecided++;
                }
            }
            console.log(upvote + undecided);
        }
    }
});

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++){
		nl.num();
		let cnt = nl.nums().reduce((ac, e) => (e != 2)?ac + 1:ac, 0);
		ans.push(cnt);
	}
	console.log(ans.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++){
		nl.num();
		let cnt = nl.nums().filter(e => e != 2).length;
		ans.push(cnt);
	}
	console.log(ans.join('\n'));
};

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

//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 list = nextIntArray(N);
		var L = 0;
		var R = 0;
		for(var j = 0; j < N; j++){
			if(list[j] != 2){
				L++;
			}
		}
		myout(L);
	}
}

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 upvote = 0
            var downvote = 0
            var undecided = 0
            for(var l = 0; l < e; l++){
                if(k[l] == 1){
                    upvote++
                }else if(k[l] == 2){
                    downvote++
                }else{
                    undecided++
                }
            }
            console.log(upvote + undecided);
        }
    }
})

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 j = 1;
    for (var m = 1; m <= t; m++) {
        var n = Number(input[j]);
        j++;
        var arr = input[j].split(" ").map((i) => {
            return Number(i);
        });
        j++;
        var count = 0;
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] === 1 || arr[i] === 3) {
                count++;
            }
        }
        console.log(count);
    }
})

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++];
}

function main(){
    let t = +readLine();
    while(t--){
        let n = +readLine();
        let a = readLine().split(' ').map(Number);
        let ans = 0;
        for(let i=0; i<a.length; i++){
            if(a[i] === 2){
                continue;
            }
            ans++;
        }
        console.log(ans);
    }
}

'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 r = readLine().split(' ').map(Number);

        let max = 0;

        for(let i = 0 ; i < n ; i++){
            max += r[i] === 2 ? 0 : 1;
        }

        console.log(max);
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

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

'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++];
}

var maxN = 2 * 1e5 + 10
var mod = BigInt(1e9 + 7)

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [n, m] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    })
    var l1 = 0
    var d1 = 0
    var l2 = 0
    var d2 = 0

    for (let i = 0; i < n; i++) {
      if (a[i] === 1) {
        l1 += 1
      }
      if (a[i] === 2) {
        d2 += 1
      }
      if (a[i] === 3 && l1 === 0) {
        l1 = 1
        continue
      }
      if (a[i] === 3 && d2 >= l2) {
        l2 += 1
      } else {
        d2 += 1
      }
    }

    console.log(l1 + l2)

  })
}

'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++];
}

var maxN = 2 * 1e5 + 10
var mod = BigInt(1e9 + 7)

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [n, m] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    // var [x, y] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    })
    var l1 = 0
    var d1 = 0
    var l2 = 0
    var d2 = 0

    for (let i = 0; i < n; i++) {
      if (a[i] === 1) {
        l2 += 1
      }
      if (a[i] === 2) {
        d1 += 1
      }
      if (a[i] === 3 && d1 >= l1) {
        l1 += 1
        continue
      }
      if (a[i] === 3 && d2 >= l2) {
        l2 += 1
        continue
      }
      if (a[i] === 3) d1++
    }

    console.log(l1 + l2)

  })
}

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(var j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number);
            var upvote = 0;
            var downvote = 0;
            for(var l = 0; l < e; l++){
                if(k[l] == 1){
                    upvote++;
                }else if(k[l] == 2){
                    downvote++;
                }else{
                    if(downvote > upvote){
                        downvote++;
                    }else{
                        upvote++;
                    }
                }
            }
            console.log(upvote);
        }
    }
});

//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 list = nextIntArray(N);
		var L = 0;
		var R = 0;
		for(var j = 0; j < N; j++){
			if(list[j] == 1){
				L++;
			}else if(list[j] == 2){
				R++;
			}else{
				if(L < R){
					R++;
				}else{
					L++;
				}
			}
		}
		myout(L);
	}
}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ******** Code Start ********

function main() {

    var t=readline();
    while(t--){
        var ans=0;
        var n=readline();
        for(var i=1;i<=n;i++){
            var a=readline();
            if(a==1) ans++;
            else if(a==3) ans++;
        }
        console.log(ans);
    }

}


$$$n$$$ robots have escaped from your laboratory! You have to find them as soon as possible, because these robots are experimental, and their behavior is not tested yet, so they may be really dangerous!Fortunately, even though your robots have escaped, you still have some control over them. First of all, you know the location of each robot: the world you live in can be modeled as an infinite coordinate plane, and the $$$i$$$-th robot is currently located at the point having coordinates ($$$x_i$$$, $$$y_i$$$). Furthermore, you may send exactly one command to all of the robots. The command should contain two integer numbers $$$X$$$ and $$$Y$$$, and when each robot receives this command, it starts moving towards the point having coordinates ($$$X$$$, $$$Y$$$). The robot stops its movement in two cases:  either it reaches ($$$X$$$, $$$Y$$$);  or it cannot get any closer to ($$$X$$$, $$$Y$$$). Normally, all robots should be able to get from any point of the coordinate plane to any other point. Each robot usually can perform four actions to move. Let's denote the current coordinates of the robot as ($$$x_c$$$, $$$y_c$$$). Then the movement system allows it to move to any of the four adjacent points:  the first action allows it to move from ($$$x_c$$$, $$$y_c$$$) to ($$$x_c - 1$$$, $$$y_c$$$);  the second action allows it to move from ($$$x_c$$$, $$$y_c$$$) to ($$$x_c$$$, $$$y_c + 1$$$);  the third action allows it to move from ($$$x_c$$$, $$$y_c$$$) to ($$$x_c + 1$$$, $$$y_c$$$);  the fourth action allows it to move from ($$$x_c$$$, $$$y_c$$$) to ($$$x_c$$$, $$$y_c - 1$$$). Unfortunately, it seems that some movement systems of some robots are malfunctioning. For each robot you know which actions it can perform, and which it cannot perform.You want to send a command so all robots gather at the same point. To do so, you have to choose a pair of integer numbers $$$X$$$ and $$$Y$$$ so that each robot can reach the point ($$$X$$$, $$$Y$$$). Is it possible to find such a point?

The first line contains one integer $$$q$$$ ($$$1 \le q \le 10^5$$$) — the number of queries. Then $$$q$$$ queries follow. Each query begins with one line containing one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of robots in the query. Then $$$n$$$ lines follow, the $$$i$$$-th of these lines describes the $$$i$$$-th robot in the current query: it contains six integer numbers $$$x_i$$$, $$$y_i$$$, $$$f_{i, 1}$$$, $$$f_{i, 2}$$$, $$$f_{i, 3}$$$ and $$$f_{i, 4}$$$ ($$$-10^5 \le x_i, y_i \le 10^5$$$, $$$0 \le f_{i, j} \le 1$$$). The first two numbers describe the initial location of the $$$i$$$-th robot, and the following four numbers describe which actions the $$$i$$$-th robot can use to move ($$$f_{i, j} = 1$$$ if the $$$i$$$-th robot can use the $$$j$$$-th action, and $$$f_{i, j} = 0$$$ if it cannot use the $$$j$$$-th action). It is guaranteed that the total number of robots over all queries does not exceed $$$10^5$$$.

You should answer each query independently, in the order these queries appear in the input. To answer a query, you should do one of the following:   if it is impossible to find a point that is reachable by all $$$n$$$ robots, print one number $$$0$$$ on a separate line;  if it is possible to find a point that is reachable by all $$$n$$$ robots, print three space-separated integers on the same line: $$$1$$$ $$$X$$$ $$$Y$$$, where $$$X$$$ and $$$Y$$$ are the coordinates of the point reachable by all $$$n$$$ robots. Both $$$X$$$ and $$$Y$$$ should not exceed $$$10^5$$$ by absolute value; it is guaranteed that if there exists at least one point reachable by all robots, then at least one of such points has both coordinates not exceeding $$$10^5$$$ by absolute value.

var n = +readline();

for(var i = 0; i < n; i++) {
  var k = +readline();

  var robots = [];

  for(var j = 0; j < k; j++) {
    robots.push(readline().split(' ').map(item => +item));
  }

  var x1 = Math.max(-100000, ...robots.filter(item => item[2] === 0).map(item => item[0]));
  var y1 = Math.min(100000, ...robots.filter(item => item[3] === 0).map(item => item[1]));
  var x2 = Math.min(100000, ...robots.filter(item => item[4] === 0).map(item => item[0]));
  var y2 = Math.max(-100000, ...robots.filter(item => item[5] === 0).map(item => item[1]));
  if(x2 < x1 || y1 < y2) {
    print(0);
  } else {
    print(1, x1, y2);
  }
}

(function() {
var INPUT = ``;
var OUTPUT = ``;

var main = function() {"use strict";
    // TODO
    var q = rdN();
    while (q --> 0) {
        var n = rdN();
        var T = +100000;
        var B = -100000;
        var L = -100000;
        var R = +100000;
        for (var i = 0; i < n; ++i) {
            var input = rdArN();
            var x = input[0];
            var y = input[1];
            var f1 = input[2];
            var f2 = input[3];
            var f3 = input[4];
            var f4 = input[5];
            if (!f1) { // L-move
                L = Math.max(L, x);
            }
            if (!f2) { // T-move
                T = Math.min(T, y);
            }
            if (!f3) { // R-move
                R = Math.min(R, x);
            }
            if (!f4) { // B-move
                B = Math.max(B, y);
            }
        }
        if (L > R || B > T) {
            pr(0);
        } else {
            pr(1, L, T);
        }
    }
};

if(INPUT){INPUT=INPUT.split('\n').reverse();
readline=()=>INPUT.pop();
write=(...s)=>{OUTPUT+=[...s].join(' ')};
print=(...s)=>{write(...s);OUTPUT+='\n'};}
const rdS=readline;
const rdN=()=>+rdS();
const rdArS=()=>rdS().split(' ');
const rdArN=()=>rdArS().map(v=>+v);
const wr=write;
const pr=print;
const prAr=(a)=>pr(...a);
const prOb=(o)=>pr(JSON.stringify(o,null,4));
const cmpLt=(a,b)=>a-b;
const cmpGt=(a,b)=>b-a;
const crAr=function(length,...fillArgs){return new Array(length).fill(...fillArgs);};
const getPrimes=function(n){var sieve=crAr(n+1,true);for(var i=2,j=4;j<sieve.length;j=Math.pow(++i,2)){if(sieve[j]){for(;j<sieve.length;j+=i){sieve[j]=false;}}}var primes=[];for(i=2;i<sieve.length;++i){if(sieve[i]){primes.push(i);}}return primes;};
const defineProperty=(o,pN,v)=>Object.defineProperty(o,pN,{configurable:true,enumerable:false,value:v});
defineProperty(Array.prototype,'sortLt',function(){return this.sort(cmpLt);});
defineProperty(Array.prototype,'sortGt',function(){return this.sort(cmpGt);});
defineProperty(Set.prototype,'union',function(s){return new Set([...this,...s]);});
defineProperty(Set.prototype,'intersection',function(s){return new Set([...this].filter((v)=>s.has(v)));});
defineProperty(Set.prototype,'difference',function(s){return new Set([...this].filter((v)=>!s.has(v)));});

main();
return OUTPUT;
})();

var n = +readline();

for(var i = 0; i < n; i++) {
  var k = +readline();

  var robots = [];

  for(var j = 0; j < k; j++) {
    robots.push(readline().split(' ').map(item => +item));
  }

  var x1 = Math.max(...robots.filter(item => item[2] === 0).map(item => item[0]));
  var y1 = Math.min(...robots.filter(item => item[3] === 0).map(item => item[1]));
  var x2 = Math.min(...robots.filter(item => item[4] === 0).map(item => item[0]));
  var y2 = Math.max(...robots.filter(item => item[5] === 0).map(item => item[1]));
  x1 === -Infinity && (x1 = -10000);
  y1 === Infinity && (y1 = 10000);
  x2 === Infinity && (x2 = 10000);
  y2 === -Infinity && (y2 = -10000);
  if(x2 < x1 || y1 < y2) {
    print(0);
  } else {
    print(1, x1, y2);
  }
}

(function() {
var INPUT = ``;
var OUTPUT = ``;

var main = function() {"use strict";
    // TODO
    var q = rdN();
    while (q --> 0) {
        var n = rdN();
        var T = +100000;
        var B = -100000;
        var L = -100000;
        var R = +100000;
        for (var i = 0; i < n; ++i) {
            var input = rdArN();
            var x = input[0];
            var y = input[1];
            var f1 = input[2];
            var f2 = input[3];
            var f3 = input[4];
            var f4 = input[5];
            if (!f1) { // L-move
                L = Math.max(L, x);
            }
            if (!f2) { // T-move
                T = Math.min(T, x);
            }
            if (!f3) { // R-move
                R = Math.min(R, x);
            }
            if (!f4) { // B-move
                B = Math.max(B, x);
            }
        }
        if (L > R || B > T) {
            pr(0);
        } else {
            pr(1, L, T);
        }
    }
};

if(INPUT){INPUT=INPUT.split('\n').reverse();
readline=()=>INPUT.pop();
write=(...s)=>{OUTPUT+=[...s].join(' ')};
print=(...s)=>{write(...s);OUTPUT+='\n'};}
const rdS=readline;
const rdN=()=>+rdS();
const rdArS=()=>rdS().split(' ');
const rdArN=()=>rdArS().map(v=>+v);
const wr=write;
const pr=print;
const prAr=(a)=>pr(...a);
const prOb=(o)=>pr(JSON.stringify(o,null,4));
const cmpLt=(a,b)=>a-b;
const cmpGt=(a,b)=>b-a;
const crAr=function(length,...fillArgs){return new Array(length).fill(...fillArgs);};
const getPrimes=function(n){var sieve=crAr(n+1,true);for(var i=2,j=4;j<sieve.length;j=Math.pow(++i,2)){if(sieve[j]){for(;j<sieve.length;j+=i){sieve[j]=false;}}}var primes=[];for(i=2;i<sieve.length;++i){if(sieve[i]){primes.push(i);}}return primes;};
const defineProperty=(o,pN,v)=>Object.defineProperty(o,pN,{configurable:true,enumerable:false,value:v});
defineProperty(Array.prototype,'sortLt',function(){return this.sort(cmpLt);});
defineProperty(Array.prototype,'sortGt',function(){return this.sort(cmpGt);});
defineProperty(Set.prototype,'union',function(s){return new Set([...this,...s]);});
defineProperty(Set.prototype,'intersection',function(s){return new Set([...this].filter((v)=>s.has(v)));});
defineProperty(Set.prototype,'difference',function(s){return new Set([...this].filter((v)=>!s.has(v)));});

main();
return OUTPUT;
})();


You are given an array $$$a$$$ of $$$n$$$ positive integers numbered from $$$1$$$ to $$$n$$$. Let's call an array integral if for any two, not necessarily different, numbers $$$x$$$ and $$$y$$$ from this array, $$$x \ge y$$$, the number $$$\left \lfloor \frac{x}{y} \right \rfloor$$$ ($$$x$$$ divided by $$$y$$$ with rounding down) is also in this array.You are guaranteed that all numbers in $$$a$$$ do not exceed $$$c$$$. Your task is to check whether this array is integral.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$c$$$ ($$$1 \le n \le 10^6$$$, $$$1 \le c \le 10^6$$$) — the size of $$$a$$$ and the limit for the numbers in the array. The second line of each test case contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le c$$$) — the array $$$a$$$. Let $$$N$$$ be the sum of $$$n$$$ over all test cases and $$$C$$$ be the sum of $$$c$$$ over all test cases. It is guaranteed that $$$N \le 10^6$$$ and $$$C \le 10^6$$$.

For each test case print Yes if the array is integral and No otherwise.

NoteIn the first test case it is easy to see that the array is integral:   $$$\left \lfloor \frac{1}{1} \right \rfloor = 1$$$, $$$a_1 = 1$$$, this number occurs in the arry  $$$\left \lfloor \frac{2}{2} \right \rfloor = 1$$$  $$$\left \lfloor \frac{5}{5} \right \rfloor = 1$$$  $$$\left \lfloor \frac{2}{1} \right \rfloor = 2$$$, $$$a_2 = 2$$$, this number occurs in the array  $$$\left \lfloor \frac{5}{1} \right \rfloor = 5$$$, $$$a_3 = 5$$$, this number occurs in the array  $$$\left \lfloor \frac{5}{2} \right \rfloor = 2$$$, $$$a_2 = 2$$$, this number occurs in the array Thus, the condition is met and the array is integral.In the second test case it is enough to see that$$$\left \lfloor \frac{7}{3} \right \rfloor = \left \lfloor 2\frac{1}{3} \right \rfloor = 2$$$, this number is not in $$$a$$$, that's why it is not integral.In the third test case $$$\left \lfloor \frac{2}{2} \right \rfloor = 1$$$, but there is only $$$2$$$ in the array, that's why it is not integral.

'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(n, c, data) {
  const set = new Set(data);
  if (!set.has(1)) return 'NO';
  let sum = new Array(c + 10).fill(0);

  for (let i = 1; i < sum.length; i++) {
    sum[i] = sum[i - 1] + (set.has(i) ? 1 : 0);
  }

  for (let i = 2; i <= c / i; i++) {
    for (let j = i; j <= c / i; j++) {
      let left, right;

      if (set.has(i) && !set.has(j)) {
        var _sum;
        left = sum[i * j - 1], right = (_sum = sum[i * (j + 1) - 1]) !== null && _sum !== void 0 ? _sum : sum[sum.length - 1];
      } else if (set.has(j) && !set.has(i)) {
        var _sum2;
        left = sum[i * j - 1], right = (_sum2 = sum[(i + 1) * j - 1]) !== null && _sum2 !== void 0 ? _sum2 : sum[sum.length - 1];
      } else continue;

      const cur = right - left;
      if (cur) return 'NO';
    }
  }

  return 'YES';
}

// const inputs = fs.readFileSync(path.join(__dirname, './codeforces.test.txt'), 'utf-8').split('\n')

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function main() {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, c] = inputs[__ * 2 + 1].trim().split(' ').map(Number);
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    const res = solve(n, c, data);
    console.log(res);
  }
}();

'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(n, c, data) {
  const set = new Set(data);
  if (!set.has(1)) return 'NO';
  let sum = new Array(c + 10).fill(0);

  for (let i = 1; i < sum.length; i++) {
    sum[i] = sum[i - 1] + (set.has(i) ? 1 : 0);
  }

  for (let i = 2; i <= c; i++) {
    for (let j = i; j <= c / i; j++) {
      let left, right;

      if (set.has(i) && !set.has(j)) {
        var _sum;
        left = sum[i * j - 1], right = (_sum = sum[i * (j + 1) - 1]) !== null && _sum !== void 0 ? _sum : sum[sum.length - 1];
      } else if (set.has(j) && !set.has(i)) {
        var _sum2;
        left = sum[i * j - 1], right = (_sum2 = sum[(i + 1) * j - 1]) !== null && _sum2 !== void 0 ? _sum2 : sum[sum.length - 1];
      } else continue;

      const cur = right - left;
      if (cur) return 'NO';
    }
  }

  return 'YES';
}

// const inputs = fs.readFileSync(path.join(__dirname, './codeforces.test.txt'), 'utf-8').split('\n')

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function main() {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, c] = inputs[__ * 2 + 1].trim().split(' ').map(Number);
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    const res = solve(n, c, data);
    console.log(res);
  }
}();

'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(n, c, data) {
  const set = new Set(data);
  if (!set.has(1)) return 'NO';
  let sum = new Array(c + 10).fill(0);

  for (let i = 1; i < sum.length; i++) {
    sum[i] = sum[i - 1] + (set.has(i) ? 1 : 0);
  }

  for (let i = 2; i <= c / i; i++) {
    for (let j = i; j <= c / i; j++) {
      var _sum;

      const left = sum[i * j - 1],
            right = (_sum = sum[i * (j + 1) - 1]) !== null && _sum !== void 0 ? _sum : sum[sum.length - 1];
      const cur = right - left;
      if (!cur) continue;

      if (set.has(i) && !set.has(j) || set.has(j) && !set.has(i)) {
        return 'NO';
      }
    }
  }

  return 'YES';
}

// const inputs = fs.readFileSync(path.join(__dirname, './codeforces.test.txt'), 'utf-8').split('\n')

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function main() {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, c] = inputs[__ * 2 + 1].trim().split(' ').map(Number);
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    const res = solve(n, c, data);
    console.log(res);
  }
}();

'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(n, c, data) {
  data.sort((a, b) => a - b);
  const sum = [0];
  const set = new Set(data);
  if (!set.has(1)) return 'NO';

  for (let i = 1; i <= c + 10; i++) {
    sum[i] = sum[i - 1] + (set.has(i) ? 1 : 0);
  }

  for (let i = 2; i <= c / 2; i++) {
    for (let j = i; j <= c / i; j++) {
      let right = i * (j + 1) - 1 > c ? sum[sum.length - 1] : sum[i * (j + 1) - 1],
          left = i * j - 1 > c ? sum[sum.length - 1] : sum[i * j - 1];
      const cur = right - left;
      if (set.has(i) && !set.has(j) && cur || !set.has(i) && set.has(j) && cur) return 'NO';
    }
  }

  return 'YES';
}

// const inputs = fs.readFileSync(path.join(__dirname, './codeforces.test.txt'), 'utf-8').split('\n')

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function main() {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, c] = inputs[__ * 2 + 1].trim().split(' ').map(Number);
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    const res = solve(n, c, data);
    console.log(res);
  }
}();

'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(n, c, data) {
  data.sort((a, b) => a - b);
  const sum = [0];
  const set = new Set(data);
  if (!set.has(1)) return 'NO';

  for (let i = 1; i <= c; i++) {
    sum[i] = sum[i - 1] + (set.has(i) ? 1 : 0);
  }

  for (let i = 2; i <= c; i++) {
    for (let j = i; j <= c / i; j++) {
      var _sum, _sum2;

      const cur = ((_sum = sum[i * (j + 1) - 1]) !== null && _sum !== void 0 ? _sum : sum[sum.length - 1]) - ((_sum2 = sum[i * j - 1]) !== null && _sum2 !== void 0 ? _sum2 : sum[sum.length - 1]);

      if (set.has(i) && !set.has(j) && cur > 0 || !set.has(i) && set.has(j) && cur > 0) {
        return 'NO';
      }
    }
  }

  return 'YES';
}

// const inputs = fs.readFileSync(path.join(__dirname, './codeforces.test.txt'), 'utf-8').split('\n')

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function main() {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, c] = inputs[__ * 2 + 1].trim().split(' ').map(Number);
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    const res = solve(n, c, data);
    console.log(res);
  }
}();

'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(n, c, data) {
  data.sort((a, b) => a - b);
  const sum = [0];
  const set = new Set(data);
  if (!set.has(1)) return 'NO';

  for (let i = 1; i <= c; i++) {
    sum[i] = sum[i - 1] + (set.has(i) ? 1 : 0);
  }

  for (let i = 2; i <= c / i; i++) {
    for (let j = i; j <= c / i; j++) {
      var _sum, _sum2;

      const cur = ((_sum = sum[i * (j + 1) - 1]) !== null && _sum !== void 0 ? _sum : sum[sum.length - 1]) - ((_sum2 = sum[i * j - 1]) !== null && _sum2 !== void 0 ? _sum2 : sum[sum.length - 1]);

      if (set.has(i) && !set.has(j) && cur > 0 || !set.has(i) && set.has(j) && cur > 0) {
        return 'NO';
      }
    }
  }

  return 'YES';
}

// const inputs = fs.readFileSync(path.join(__dirname, './codeforces.test.txt'), 'utf-8').split('\n')

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function main() {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, c] = inputs[__ * 2 + 1].trim().split(' ').map(Number);
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    const res = solve(n, c, data);
    console.log(res);
  }
}();

'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(n, c, data) {
  data.sort((a, b) => a - b);
  const sum = [0];
  const set = new Set(data);
  if (!set.has(1)) return 'NO';

  for (let i = 1; i <= c; i++) {
    sum[i] = sum[i - 1] + (set.has(i) ? 1 : 0);
  }

  for (let i = 2; i <= c / i; i++) {
    for (let j = i; j <= c / i; j++) {
      var _sum;

      const cur = ((_sum = sum[i * (j + 1) - 1]) !== null && _sum !== void 0 ? _sum : sum[sum.length - 1]) - sum[i * j - 1];

      if (set.has(i) && !set.has(j) && cur > 0 || !set.has(i) && set.has(j) && cur > 0) {
        return 'NO';
      }
    }
  }

  return 'YES';
}

// const inputs = fs.readFileSync(path.join(__dirname, './codeforces.test.txt'), 'utf-8').split('\n')

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function main() {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, c] = inputs[__ * 2 + 1].trim().split(' ').map(Number);
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    const res = solve(n, c, data);
    console.log(res);
  }
}();

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

class SegTree {
  constructor(n) {
    this.n = n;
    this.root = this._newNode(0, n);
    this.add = this._add.bind(this, this.root);
    this.query = this._query.bind(this, this.root);
  }

  _newNode(l, r, val = false, left = null, right = null) {
    return {
      val,
      l,
      r,
      left,
      right
    };
  }

  _add(node, x) {
    if (!node) return;
    const {
      l,
      r
    } = node;

    if (l === r) {
      node.val = true;
      return;
    }

    const mid = Math.floor((l + r) / 2);

    if (!node.left) {
      node.left = this._newNode(l, mid);
      node.right = this._newNode(mid + 1, r);
    }

    if (x <= mid) this._add(node.left, x);else this._add(node.right, x);
    node.val = node.left.val || node.right.val;
  }

  _query(node, x, y) {
    if (y < x) return false;
    if (!node) return false;
    const {
      l,
      r
    } = node;
    if (l === x && r === y) return node.val;
    let res = false,
        mid = Math.floor((l + r) / 2);
    if (y <= mid) res = this._query(node.left, x, y);else if (x > mid) res = this._query(node.right, x, y);else res = this._query(node.left, x, mid) || this._query(node.right, mid + 1, y);
    return res;
  }

}

function solve(n, c, data) {
  data.sort((a, b) => a - b);
  const segTree = new SegTree(c + 10);

  for (let num of data) {
    segTree.add(num);
  }

  const set = new Set(data);
  if (!set.has(1)) return 'NO';

  const primes = [],
        nums = new Array(c).fill(1);
  nums[0] = nums[1] = 0;

  for (let i = 2; i <= c; i++) {
    if (nums[i]) primes.push(i);

    for (let j of primes) {
      const k = j * i;
      if (k > c) break;
      nums[k] = 0;
      if (set.has(i) || set.has(j)) {
        const hasProduct = segTree.query(k, (i + 1) * j - 1);

        if (set.has(i) && !set.has(j) && hasProduct || !set.has(i) && set.has(j) && hasProduct) {
          return 'NO';
        }
      }

      if (i % k === 0) break;
    }
  }

  return 'YES';
}

// const inputs = fs.readFileSync(path.join(__dirname, './codeforces.test.txt'), 'utf-8').split('\n')

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function main() {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, c] = inputs[__ * 2 + 1].trim().split(' ').map(Number);
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    const res = solve(n, c, data);
    console.log(res);
  }
}();

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

class SegTree {
  constructor(n) {
    this.n = n;
    this.root = this._newNode(0, n);
    this.add = this._add.bind(this, this.root);
    this.query = this._query.bind(this, this.root);
  }

  _newNode(l, r, val = false, left = null, right = null) {
    return {
      val,
      l,
      r,
      left,
      right
    };
  }

  _add(node, x) {
    if (!node) return;
    const {
      l,
      r
    } = node;

    if (l === r) {
      node.val = true;
      return;
    }

    const mid = Math.floor((l + r) / 2);

    if (!node.left) {
      node.left = this._newNode(l, mid);
      node.right = this._newNode(mid + 1, r);
    }

    if (x <= mid) this._add(node.left, x);else this._add(node.right, x);
    node.val = node.left.val || node.right.val;
  }

  _query(node, x, y) {
    if (y < x) return false;
    if (!node) return false;
    const {
      l,
      r
    } = node;
    if (l === x && r === y) return node.val;
    let res = false,
        mid = Math.floor((l + r) / 2);
    if (y <= mid) res = this._query(node.left, x, y);else if (x > mid) res = this._query(node.right, x, y);else res = this._query(node.left, x, mid) || this._query(node.right, mid + 1, y);
    return res;
  }

}

function solve(n, c, data) {
  data.sort((a, b) => a - b);
  const segTree = new SegTree(c + 10);

  for (let num of data) {
    segTree.add(num);
  }

  const set = new Set(data);
  if (!set.has(1)) return 'NO';

  const primes = [],
        nums = new Array(c).fill(1);
  nums[0] = nums[1] = 0;

  for (let i = 2; i <= c; i++) {
    if (nums[i]) primes.push(i);

    for (let j of primes) {
      const k = j * i;
      if (k > c) break;
      nums[k] = 0;
      const hasProduct = segTree.query(k, (i + 1) * j - 1);

      if (set.has(i) && !set.has(j) && hasProduct || !set.has(i) && set.has(j) && hasProduct) {
        return 'NO';
      }

      if (i % k === 0) break;
    }
  }

  return 'YES';
}

// const inputs = fs.readFileSync(path.join(__dirname, './codeforces.test.txt'), 'utf-8').split('\n')

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function main() {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, c] = inputs[__ * 2 + 1].trim().split(' ').map(Number);
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    const res = solve(n, c, data);
    console.log(res);
  }
}();

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

class SegTree {
  constructor(n) {
    this.n = n;
    this.root = this._newNode(0, n);
    this.add = this._add.bind(this, this.root);
    this.query = this._query.bind(this, this.root);
  }

  _newNode(l, r, val = false, left = null, right = null) {
    return {
      val,
      l,
      r,
      left,
      right
    };
  }

  _add(node, x) {
    if (!node) return;
    const {
      l,
      r
    } = node;

    if (l === r) {
      node.val = true;
      return;
    }

    const mid = Math.floor((l + r) / 2);

    if (!node.left) {
      node.left = this._newNode(l, mid);
      node.right = this._newNode(mid + 1, r);
    }

    if (x <= mid) this._add(node.left, x);else this._add(node.right, x);
    node.val = node.left.val || node.right.val;
  }

  _query(node, x, y) {
    if (y < x) return false;
    if (!node) return false;
    const {
      l,
      r
    } = node;
    if (l === x && r === y) return node.val;
    let res = false,
        mid = Math.floor((l + r) / 2);
    if (y <= mid) res = this._query(node.left, x, y);else if (x > mid) res = this._query(node.right, x, y);else res = this._query(node.left, x, mid) || this._query(node.right, mid + 1, y);
    return res;
  }

}

function solve(n, c, data) {
  data.sort((a, b) => a - b);
  const segTree = new SegTree(c + 10);

  for (let num of data) {
    segTree.add(num);
  }

  const set = new Set(data);
  if (!set.has(1)) return 'NO';

  for (let i = 2; i < c; i++) {
    let hasi = set.has(i);

    for (let j = i; j * i <= c; j++) {
      const hasProduct = segTree.query(i * j, i * (j + 1) - 1);
      if (hasi && set.has(j) && hasProduct || !hasi && !set.has(j) && !hasProduct) continue;
      return 'NO';
    }
  }

  return 'YES';
}

// const inputs = fs.readFileSync(path.join(__dirname, './codeforces.test.txt'), 'utf-8').split('\n')

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function main() {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, c] = inputs[__ * 2 + 1].trim().split(' ').map(Number);
    const data = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    const res = solve(n, c, data);
    console.log(res);
  }
}();