Alice gave Bob two integers $$$a$$$ and $$$b$$$ ($$$a > 0$$$ and $$$b \ge 0$$$). Being a curious boy, Bob wrote down an array of non-negative integers with $$$\operatorname{MEX}$$$ value of all elements equal to $$$a$$$ and $$$\operatorname{XOR}$$$ value of all elements equal to $$$b$$$.What is the shortest possible length of the array Bob wrote?Recall that the $$$\operatorname{MEX}$$$ (Minimum EXcluded) of an array is the minimum non-negative integer that does not belong to the array and the $$$\operatorname{XOR}$$$ of an array is the bitwise XOR of all the elements of the array.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The only line of each test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \leq a \leq 3 \cdot 10^5$$$; $$$0 \leq b \leq 3 \cdot 10^5$$$) — the $$$\operatorname{MEX}$$$ and $$$\operatorname{XOR}$$$ of the array, respectively.

For each test case, output one (positive) integer — the length of the shortest array with $$$\operatorname{MEX}$$$ $$$a$$$ and $$$\operatorname{XOR}$$$ $$$b$$$. We can show that such an array always exists.

NoteIn the first test case, one of the shortest arrays with $$$\operatorname{MEX}$$$ $$$1$$$ and $$$\operatorname{XOR}$$$ $$$1$$$ is $$$[0, 2020, 2021]$$$.In the second test case, one of the shortest arrays with $$$\operatorname{MEX}$$$ $$$2$$$ and $$$\operatorname{XOR}$$$ $$$1$$$ is $$$[0, 1]$$$.It can be shown that these arrays are the shortest arrays possible.

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}

const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let [n, m] = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let k;
    if (n % 4 === 1) k = n - 1;
    else if (n % 4 === 3) k = n;
    else if (n % 4 === 2) k = 1;
    else k = 0;
    if (k === m) console.log(n);
    else if ((k ^ m) !== n) console.log(n + 1);
    else console.log(n + 2);
  }
};
solve();

//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] = BigInt(next());
		}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 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 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();
	var list = new Array(400000).fill(0);
	for(var i = 1; i < 400000; i++){
		list[i] = i ^ list[i - 1];
	}
	while(hasNext()){
		var A = nextInt();
		var B = nextInt();
		var xor = list[A - 1];
		if(xor == B){
			myout(A);
		}else if((xor ^ B) != A){
			myout(A + 1);
		}else{
			myout(A + 2);
		}
	}
}

var n = parseInt(readline());
var xorList = [0];
var baseX = 0;
for (var x = 0; x < (3e5) + 10; x++){
    baseX = baseX^x;
    xorList.push(baseX);
}
var outList = [];
while(n--) {
    var cellList = readline().split(' ').map(v => parseInt(v));
    var baseX = xorList[cellList[0]]
    baseX ^= cellList[1];
    // console.log(cellList[0],cellList[1], baseX);
    if (baseX === 0){
        outList.push(cellList[0])
    }
    else if(cellList[0] === baseX){
        // console.log("2")
        outList.push(cellList[0] + 2)
    }else {
        outList.push(cellList[0] + 1)

    }
}

print(outList.join('\n'))

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}

const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let [n, m] = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    if (n === 1) {
      if (m === 1) console.log(3);
      else console.log(2);
      continue;
    }
    let k = n - 1,
      r;
    if (k % 4 === 1 || k % 4 === 3) {
      r = k % 4 === 1 ? 1 : 0;
    } else {
      r = k % 4 === 0 ? k : k + 1;
    }
    if (r === 0) {
      if (n === m) console.log(n + 2);
      else if (r === m) console.log(n);
      else console.log(n + 1);
    } else if (r === 1) {
      if (m - n === 1) console.log(n + 2);
      else if (r === m) console.log(n);
      else console.log(n + 1);
    } else if (r === k) {
      if (m === 1) console.log(n + 2);
      else if (r === m) console.log(n);
      else console.log(n + 1);
    } else {
      if (r === m) console.log(n);
      else console.log(n + 1);
    }
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}

const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let [n, m] = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    if (n === 1) {
      if (m === 1) console.log(3);
      else console.log(2);
      continue;
    }
    let k = n - 1;
    if (k % 4 === 1 || k % 4 === 3) {
      let r = k % 4 === 1 ? 1 : 0;
      if (r === m) console.log(n);
      else console.log(n + 1);
    } else {
      let r = k % 4 === 0 ? k : k + 1;
      if (r === k) {
        if (m === 1) console.log(n + 2);
        else if (r === m) console.log(n);
        else console.log(n + 1);
      } else {
        if (r === m) console.log(n);
        else console.log(n + 1);
      }
    }
  }
};
solve();

//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] = BigInt(next());
		}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 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 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();
	var list = new Array(400000).fill(0);
	for(var i = 1; i < 400000; i++){
		list[i] = i ^ list[i - 1];
	}
	while(hasNext()){
		var A = nextInt();
		var B = nextInt();
		if(A == 1 && B == 1){
			myout(3);
			continue;
		}
		var xor = list[A - 1];
		if(xor == B){
			myout(A);
		}else{
			myout(A + 1);
		}
	}
}


There are $$$n$$$ cats in a line, labeled from $$$1$$$ to $$$n$$$, with the $$$i$$$-th cat at position $$$i$$$. They are bored of gyrating in the same spot all day, so they want to reorder themselves such that no cat is in the same place as before. They are also lazy, so they want to minimize the total distance they move. Help them decide what cat should be at each location after the reordering.For example, if there are $$$3$$$ cats, this is a valid reordering: $$$[3, 1, 2]$$$. No cat is in its original position. The total distance the cats move is $$$1 + 1 + 2 = 4$$$ as cat $$$1$$$ moves one place to the right, cat $$$2$$$ moves one place to the right, and cat $$$3$$$ moves two places to the left.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first and only line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 100$$$) — the number of cats. It can be proven that under the constraints of the problem, an answer always exist.

Output $$$t$$$ answers, one for each test case. Each answer consists of $$$n$$$ integers — a permutation with the minimum total distance. If there are multiple answers, print any.

NoteFor the first test case, there is only one possible permutation that satisfies the conditions: $$$[2, 1]$$$.The second test case was described in the statement. Another possible answer is $$$[2, 3, 1]$$$.

var t = parseInt(readline());
while (t--) {
    var n = parseInt(readline());
    if (n % 2 === 0) {
        for (var i = 1; i < n; i += 2) write(i + 1 + ' ' + i + ' ');
        write('\n');
    } else {
        write('3 1 2 ');
        for (var i = 4; i < n; i += 2) write(i + 1 + ' ' + i + ' ');
        write('\n');
    }
}

var t = parseInt(readline());
while (t--) {
    var n = parseInt(readline());
    if (n % 2 == 0) {
        for (var i = 1; i < n; i += 2) write(i + 1 + ' ' + i + ' ');
        write('\n');
    } else {
        write('3 1 2 ');
        for (var i = 4; i < n; i += 2) write(i + 1 + ' ' + i + ' ');
        write('\n');
    }
}

var t = parseInt(readline());
while (t--) {
    var n = parseInt(readline());
    if (n % 2 == 0) {
        for (var i = 1; i < n; i += 2) write(i + 1 + ' ' + i + ' ');
    } else {
        write('3 1 2 ');
        for (var i = 4; i < n; i += 2) write(i + 1 + ' ' + i + ' ');
    }
}

var t = parseInt(readline());
while(t--) {
    var n = parseInt(readline());
    if(n%2 == 0) {
        for(var i=1; i<n; i+=2) write(i+1 +' '+ i +' ');
        print();
    }
    else {
        write('3 1 2 ');
        for(var i=4; i<n; i+= 2) write(i+1 +' '+ i +' ');
        print();
    }
}

var t = parseInt(readline());
while(t--) {
    var n = parseInt(readline());
    if(n%2 == 0) {
        for(var i=1; i<n; i+=2) write(i+1 +' '+ i +' ');
    }
    else {
        write('3 1 2 ');
        for(var i=4; i<n; i+= 2) write(i+1 +' '+ i +' ');
    }
}

var t = parseInt(readline());
while(t--) {
    var n = parseInt(readline());
    if(n%2 === 0) {
        for(var i=1; i<n; i+=2) write(i+1 +' '+ i +' ');
    }
    else {
        write('3 1 2 ');
        for(var i=4; i<n; i+= 2) write(i+1 +' '+ i +' ');
    }
}

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(var l = 1; l <= n; l++){
        var a = 2;
        var b = a - 1;
        var answer = '';
        var k = lines[l];
        if(k % 2 === 0){
            for(var j = 0; j < k / 2; j++){
                answer += a + ' ' + b + ' ';
                a += 2;
                b = a - 1;
            }
        }else{
            answer = 3 + ' ' + 1 + ' ' + 2 + ' ';
            a = 5;
            b = 0;
            for(var h = 3; h < k; h++){
                if(b % 2 === 0){
                    answer += a + ' ';
                    b = 1;
                }else{
                    answer += a - 1 + ' ';
                    b = 0;
                    a += 2;
                }
            }
        }
        console.log(answer);
    }
});

"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 = parseInt(readline());
    while(t--) {
        var n = parseInt(readline());
        if(n%2 == 0) {
            for(var i=1; i<n; i+=2) print(i+1 +' '+ i +' ');
        }
        else {
            print('3 1 2 ');
            for(var i=4; i<n; i+= 2) print(i+1 +' '+ i +' ');
        }
    }

}

//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] = BigInt(next());
		}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 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 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 list = [];
		for(var i = 1; i <= N; i++){
			list.push(i);
		}
		for(var i = 0; i < N - 1; i += 2){
			var tmp = list[i];
			list[i] = list[i + 1];
			list[i + 1] = tmp;
		}
		if(N % 2 == 1){
			var tmp = list[N - 2];
			list[N - 2] = list[N - 1];
			list[N - 1] = tmp;
		}
		myout(myconv(list, 8));
	}
}

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

function div(a, b) {
   return Math.floor(a / b);
}

function solve() {
   var n = Number(read());
   arr = []
   for (var i = 1; i < n; i++) {
      if (i & 1) {
         arr.push(i + 1);
         continue;
      }
      arr.push(i - 1);
   }
   if (n & 1) {
      arr.push(arr[n - 2]);
      arr[n - 2] = n;
   } else {
      arr.push(n - 1);
   }
   write(arr.join(' '));
}

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

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

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = +lines[0]
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        console.log(solve(n));
    }
});

function solve(n) {
    const r = []
    let start = 1
    if (n & 1) {
        r[1] = 3
        r[2] = 1
        r[3] = 2
        start = 4
    }
    for (let i = start; i <= n; i++) {
        r[i] = ((i - start) & 1) ? i - 1 : i + 1
    }
    r.shift() // 0
    return r.join(' ')
}

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => {
        let next;
        do {
            next = (await getLineGen.next());
        } while (!next.done && next.value === '');
        return next.value;
    };
})();

let solve = async () => {
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        const n = parseInt(await getLine());
        if (n === 1) {
            rl.output.write(1+ '\n');
            continue;
        }

        if (n%2 === 0) {
            for(let i = 1; i <= n; i += 2) {
               if (i > 1)
                   rl.output.write(' ');
               rl.output.write((i+1) + ' ' + i);
            }
            rl.output.write('\n');
        } else {
            for(let i = 1; i <= n - 3; i += 2) {
                if (i > 1)
                    rl.output.write(' ');
                rl.output.write((i+1) + ' ' + i);
            }
            if (n > 3)
                rl.output.write(' ');
            rl.output.write(n + ' ' + (n - 2) + ' ' + (n - 1) + '\n');
        }
    }

}

solve();

const stdin = process.openStdin();
let content = '';

stdin.addListener('data', (data) => {
          content += data;
})

stdin.addListener('end', () => {
          content = content.split('\n');
          content.shift();
          content = content.map((string) => string.substring(0, string.length - 1));
          content.pop();
          content.forEach((str) => {
                    const num = parseInt(str);
                    console.log(prettyPermutations(num));
          });
})

const prettyPermutations = (num) => {
          let ans = new Array(num).fill(0);
          ans = ans.map((_, i) => i + 1);
          for (let i = 1; i < num; i++) {
                    if (i % 2 === 1 || i === num - 1) [ans[i - 1], ans[i]] = [ans[i], [ans[i - 1]]];
          }
          return ans.join(' ');
}

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 n = nl.num();
		let r = [];
		for(let j = 0; j < n - n%2; j += 2){
			r.push(j + 2);
			r.push(j + 1);
		}
		if (n%2 === 1){
			r.push(n);
			[r[n-1] , r[n-2]] = [r[n-2], r[n-1]];
		}
		ans.push(r);
	}
	console.log(ans.map(e => e.join(' ')).join('\n'));
};

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

var t = parseInt(readline());
var i = 1;
while (t--) {
    var n = parseInt(readline());
    if (n % 2 === 1) {
        write('3 1 2 ');
        i = 4;
    }

    for (; i < n; i += 2) write(i + 1 + ' ' + i + ' ');
    write('\n');
}

var t = parseInt(readline());
while (t--) {
    const n = parseInt(readline());
    if (n % 2 == 0) {
        for (var i = 1; i < n; i += 2) write(i + 1 + ' ' + i + ' ');
    } else {
        write('3 1 2 ');
        for (var i = 4; i < n; i += 2) write(i + 1 + ' ' + i + ' ');
    }
}

var t = parseInt(readline());
while(t--) {
    var n = parseInt(readline());
    write(n+' ');
    for(var i=1; i<n; i++) write(i+' ');
    print()
}

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 ++){
        var s = []
        var d = ''
        for(k = 1; k <= lines[j]; k++){
            s.push(k)
        }
        s = s.sort(function(a, b){return b - a});
        d += s[0] + ' '
        s = s.sort(function(a, b){return a - b});

        for(l = 0; l < s.length - 1; l++){
            d += s[l] + ' '
        }
        console.log(d)
    }

});

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 ++){
        var s = []
        var d = ''
        for(k = 1; k <= lines[j]; k++){
            s.push(k)
        }
        s.sort(function(a, b){return b - a});
        d += s[0]
        for(l = 0; l <= s.length; l++){
            d += s[l]
        }
        console.log(d)
    }

});

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 ++){
        var s = ''
        for(k = 1; k <= lines[j]; k++){
            s += k + ' '
        }
        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 n = lines[0];
    for(j = 1; j <= n; j ++){
        var s = ''
        for(k = 0; k < lines[j]; k++){
            s += k + ''
        }
        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 n = lines[0];

    for(j = 1; j <= n;j ++){
        var a = lines[j].split(' ').map(Number)
        console.log((a[1] + a[0]))
    }
});

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(var l = 1; l <= n; l++){
        var a = 2;
        var b = a - 1;
        var answer = '';
        var k = lines[l];
        if(k % 2 === 0){
            for(var j = 0; j < k / 2; j++){
                answer += a + ' ' + b + ' ';
                a += 2;
                b = a - 1;
            }
        }else{
            answer = 3 + ' ' + 1 + ' ' + 2 + ' ';
            a = 5;
            b = 0;
            for(var h = 3; h < k; h++){
                if(b % 2 === 0){
                    answer += a + ' ';
                    b = 1;
                }else{
                    answer += a - 1 + ' ';
                    b = 0;
                    a += 3;
                }
            }
        }
        console.log(answer);
    }
});

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];
    console.log(2 + ' ' + 1 + "\n" + 3 + ' ' + 1 + ' ' + 2)
});

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];
    console.log(2 + ' ' + 3 + "\n" + 3 + ' ' + 1 + ' ' + 2)
});

"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 = parseInt(readline());
    while(t--) {
        var n = parseInt(readline());
        if(n%2 == 0) {
            for(var i=1; i<n; i+=2) print(i+1 +' '+ i +' ');
            print();
        }
        else {
            print('3 1 2 ');
            for(var i=4; i<n; i+= 2) print(i+1 +' '+ i +' ');
            print();
        }
    }

}

//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] = BigInt(next());
		}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 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 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 list = [];
		for(var i = 1; i <= N; i++){
			list.push(i);
		}
		var tmp = list.pop();
		list.unshift(tmp);
		myout(myconv(list, 8));
	}
}

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

function div(a, b) {
   return Math.floor(a / b);
}

function solve() {
   var n = Number(read());
   var arr = [n];
   for (var i = 1; i < n; i++) arr.push(i);
   write(arr.join(' '));
}

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

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

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = +lines[0]
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        console.log(solve(n));
    }
});

function solve(n) {
    const r = []
    let start = 1
    if (n & 1) {
        r[1] = 3
        r[2] = 2
        r[3] = 1
        start = 4
    }
    for (let i = start; i <= n; i++) {
        r[i] = ((i - start) & 1) ? i - 1 : i + 1
    }
    r.shift() // 0
    return r.join(' ')
}

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => {
        let next;
        do {
            next = (await getLineGen.next());
        } while (!next.done && next.value === '');
        return next.value;
    };
})();

let solve = async () => {
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        const n = parseInt(await getLine());
        if (n === 1) {
            rl.write(1+ '\n');
            continue;
        }

        if (n%2 === 0) {
            for(let i = 1; i <= n; i += 2) {
               if (i > 1)
                   rl.write(' ');
               rl.write((i+1) + ' ' + i);
            }
            rl.write('\n');
        } else {
            for(let i = 1; i <= n - 3; i += 2) {
                if (i > 1)
                    rl.write(' ');
                rl.write((i+1) + ' ' + i);
            }
            if (n > 3)
                rl.write(' ');
            rl.write(n + ' ' + (n - 2) + ' ' + (n - 1) + '\n');
        }
    }

}

solve();


You have array a1, a2, ..., an. Segment [l, r] (1 ≤ l ≤ r ≤ n) is good if ai = ai - 1 + ai - 2, for all i (l + 2 ≤ i ≤ r).Let's define len([l, r]) = r - l + 1, len([l, r]) is the length of the segment [l, r]. Segment [l1, r1], is longer than segment [l2, r2], if len([l1, r1]) > len([l2, r2]).Your task is to find a good segment of the maximum length in array a. Note that a segment of length 1 or 2 is always good.

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of elements in the array. The second line contains integers: a1, a2, ..., an (0 ≤ ai ≤ 109).

Print the length of the longest good segment in array a.

print(function(n, a) {
	var ans = 0,
		cnt = 0;
	if (a.length < 3) return a.length;
	for (var i = 0; i < n; i++)
		if (a[i] + a[i + 1] === a[i + 2]) {
			cnt++;
		} else {
			ans = Math.max(ans, cnt + 2);
			cnt = 0;
	}

	return ans;

}(+readline(), readline().split(' ').map(Number)));

var arrayLength = parseInt(readline())
var array = readline().split(' ').map(c => parseInt(c))
if (arrayLength < 3){
	print(arrayLength)
}
else {
	var size = [2], flag = false, count = 0, ans = 0
	for (var i = 2; i < arrayLength; i++){
		if (array[i-1]+array[i-2] == array[i]){
			if (!flag){
				count += 1; flag = true
			}
			else{
				count +=1
			}
		}
		else{
			if (flag){
				flag = false
				size.push(count+2)
				count = 0
			}
		}
	}
	size.push(count+2)
	size.forEach((val) => {
		if (val > ans){
			ans = val
		}
	})
	print(ans)
}

;(function () {

    print(function (n, a) {
        if (n < 3) {
            return n;
        }

        var q = [];
        for (var i = 2; i < n; i++) {
            if (a[i] === a[i - 1] + a[i - 2]) {
                if (q.length > 0) {
                    var z = +q.slice(-1);
                    if (z !== (i - 1)) {
                        q.push('|');
                    }
                }
                q.push(i);
            }
        }
        return 2 + Math.max.apply(null, q.map(function (e) { return e === '|' ? e : '0'; }).join('').split('|').map(function (e) { return e.length; }));
    }.apply(null, [+readline(), readline().split(' ').map(Number)]));

}.call(this));

print(function(n, a) {
	var ans = Math.min(a.length, 2),
		cnt = 0;
	for (var i = 0; i < n; i++)
		if (a[i] + a[i + 1] === a[i + 2]) {
			cnt++;
		} else {
			ans = Math.max(ans, cnt + 2);
			cnt = 0;
		}

	return ans;

}(+readline(), readline().split(' ').map(Number)));

print(function(n, a) {
	var ans = Math.min(2, a.length),
		cnt = ans;
	for (var i = 2; i < n; i++)
		if (a[i] === a[i - 1] + a[i - 2]) {
			cnt++;
		} else {
			ans = Math.max(ans, cnt);
			cnt = 0;
		}

	ans = Math.max(ans, cnt);
	return ans;

}(+readline(), readline().split(' ').map(Number)));

var arrayLength = parseInt(readline())
var array = readline().split(' ').map(c => parseInt(c))
if (arrayLength < 3){
	print(arrayLength)
}
else {
	var size = [2], flag = false, count = 0
	for (var i = 2; i < arrayLength; i++){
		if (array[i-1]+array[i-2] == array[i]){
			if (!flag){
				count += 1; flag = true
			}
			else{
				count +=1
			}
		}
		else{
			if (flag){
				flag = false
				size.push(count+2)
				count = 0
			}
		}
	}
	size.push(count+2)
	print(Math.max(size))
}

;(function () {

    print(function (n, a) {
        var q = [];
        for (var i = 2; i < n; i++) {
            if (a[i] === a[i - 1] + a[i - 2]) {
                if (q.length > 0) {
                    var z = +q.slice(-1);
                    if (z !== (i - 1)) {
                        q.push('|');
                    }
                }
                q.push(i);
            }
        }
        return 2 + Math.max.apply(null, q.join('').split('|').map(function (e) { return e.length; }));
    }.apply(null, [+readline(), readline().split(' ').map(Number)]));

}.call(this));

;(function () {

    print(function (n, a) {
        if (n < 3) {
            return n;
        }

        var q = [];
        for (var i = 2; i < n; i++) {
            if (a[i] === a[i - 1] + a[i - 2]) {
                if (q.length > 0) {
                    var z = +q.slice(-1);
                    if (z !== (i - 1)) {
                        q.push('|');
                    }
                }
                q.push(i);
            }
        }
        return 2 + Math.max.apply(null, q.join('').split('|').map(function (e) { return e.length; }));
    }.apply(null, [+readline(), readline().split(' ').map(Number)]));

}.call(this));


Sayaka Saeki is a member of the student council, which has $$$n$$$ other members (excluding Sayaka). The $$$i$$$-th member has a height of $$$a_i$$$ millimeters.It's the end of the school year and Sayaka wants to take a picture of all other members of the student council. Being the hard-working and perfectionist girl as she is, she wants to arrange all the members in a line such that the amount of photogenic consecutive pairs of members is as large as possible.A pair of two consecutive members $$$u$$$ and $$$v$$$ on a line is considered photogenic if their average height is an integer, i.e. $$$\frac{a_u + a_v}{2}$$$ is an integer.Help Sayaka arrange the other members to maximize the number of photogenic consecutive pairs.

The first line contains a single integer $$$t$$$ ($$$1\le t\le 500$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2000$$$)  — the number of other council members. The second line of each test case contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$)  — the heights of each of the other members in millimeters. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$.

For each test case, output on one line $$$n$$$ integers representing the heights of the other members in the order, which gives the largest number of photogenic consecutive pairs. If there are multiple such orders, output any of them.

NoteIn the first test case, there is one photogenic pair: $$$(1, 1)$$$ is photogenic, as $$$\frac{1+1}{2}=1$$$ is integer, while $$$(1, 2)$$$ isn't, as $$$\frac{1+2}{2}=1.5$$$ isn't integer.In the second test case, both pairs are photogenic.

var t = readline();
    for(var i = 0 ; i < t ; ++i){
        var n = readline(), odd = [] , even = [];
            a = readline().split(' ');
        for(var j = 0 ; j < n ; ++j){
            if(a[j] % 2 === 0){
                even.push(a[j]);
            }
            else{
                odd.push(a[j]);
            }
        }
        print(odd.join(' ') + ' ' + even.join(' '));
    }

var t = parseInt(readline());
while(t--){
    var n = parseInt(readline());
    var h = readline().split(" ").map(x => parseInt(x));
    var e = [] , o = [];
    for(var i = 0 ; i < n ; i++){
        if(h[i]&1){
            o.push(h[i]);
        } else e.push(h[i]);
    }

    var ans = "";
    e.forEach(x => ans += x+" ");
    o.forEach(x => ans += x+" ");
    print(ans);
}

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 n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var odd = [];
            var even = [];
            for(j = 0; j < n; j++){
                if(k[j] % 2 == 1){
                    odd.push(k[j]);
                }else{
                    even.push(k[j]);
                }
            }
            var a = '';
            for(j = 0; j < odd.length; j++){
                a += odd[j] + ' ';
            }
            for(j = 0; j < even.length; j++){
                a += even[j] + ' ';
            }
            console.log(a);
        }
    }
});

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
// var lines = fs.readFileSync(0, 'utf8').split('\n');
// const io = {
//   nextLine() {},
//   nextNum() {},
// };
class IO {
    constructor() {
        this.lines = [];
        this.tokens = [];
        this.lines = fs_1.default.readFileSync(0, 'utf8').split('\n');
    }
    getTokens() {
        if (!this.tokens.length) {
            this.tokens = this.nextLine().split(' ');
        }
        return this.tokens;
    }
    nextLine() {
        return this.lines.shift();
    }
    nextNum() {
        return Number(this.getTokens().shift());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
}
const io = new IO();
function solve(n, arr) {
    arr.sort((a, b) => {
        // if (a % 2 === b % 2) {
        //   return 0 ;
        // }
        return (a % 2) - (b % 2);
    });
    console.log(arr.join(' '));
}
function main() {
    let t = io.nextNum();
    while (t--) {
        let n = io.nextNum();
        let arr = io.nextNumArray(n);
        solve(n, arr);
    }
}
main();

'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(data.shift());

    while(testCases--) {

        const n = parseInt(readLine());

        const a = readLine().split(' ').map(Number);

        let res = [];

        let odd = [];
        let even = [];

        for(let i = 0; i < n; i++){
            if(a[i] % 2 === 0) even.push(a[i])
            else odd.push(a[i])
        }
        if(even.length >= odd.length){
            for(let i =0 ; i < even.length ; i++){
                res.push(even[i]);
            }
            for(let i = 0;i < odd.length; i++){
                res.push(odd[i]);
            }
        }
        else {
            for(let i = 0;i < odd.length; i++){
                res.push(odd[i]);
            }
            for(let i =0 ; i < even.length ; i++){
                res.push(even[i]);
            }
        }
        console.log(res.join(' '));
    }
});

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

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

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

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

let count = -1
let inputArr = []

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

function solve([n], arr) {
    const even = arr.filter(i => i % 2 === 0)
    const notEven = arr.filter(i => i % 2 !== 0)
    // if (even.length % 2 !== 0) {
    //     const def = even.pop()
    //     notEven.push(def)
    // }
    console.log(notEven.concat(even).join(' '))
}

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

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

	for (let i=1; i<lines.length; i+=2) {
		const arr = lines[i].trim().split(' ')
			.map(v => +v)

		const odd = [];
		const even = [];

		for (let j=0; j<arr.length; j++) {
			if (arr[j]%2 === 0) {
				even.push(arr[j]);
			} else {
				odd.push(arr[j]);
			}
		}

		console.log(odd.concat(even).join(' '));
	}

})

/**
 * 04/16/21 morning
 * https://codeforces.com/contest/1509/problem/A
 */

///////////////////////////////// pre-define /////////////////////////////////////
const pr = console.log;
///////////////////////////////////////////////////////////////////////////////////

const solve = (n, a) => {
    let odd = [];
    let even = [];
    for (const e of a) {
        e & 1 ? odd.push(e) : even.push(e);
    }
    let res = odd.concat(even);
    pr(res.join(" "))
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t--) {
            solve(input[i][0], input[i + 1]);
            i += 2;
        }
    });
};

main()

'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, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var ans = []

    for (let j = 0; j < n; j++) {
      if (a[j] % 2 === 0) ans.push(a[j])
    }
    var ans2 = []

    for (let j = 0; j < n; j++) {
      if (a[j] % 2 === 1) ans2.push(a[j])
    }

    console.log(ans.concat(ans2).join(' '))
  })
}

//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 output = [];
		for(var j = 0; j < N; j++){
			if(list[j] % 2 == 0){
				output.push(list[j]);
			}
		}
		for(var j = 0; j < N; j++){
			if(list[j] % 2 == 1){
				output.push(list[j]);
			}
		}
		myout(myconv(output, 8));
	}
}

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 ans = 0;
    while(t !== 0 && t != 1){
        if(t % 2 == 1){
            ans++;
        }
        t = Math.floor(t / 2);
    }
    console.log(ans+1);
});

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).sort(function(a, b){return b - a});
            var answer = '';
            for(var l = 0; l < e; l++){
                answer += k[l] + ' ';
            }
            console.log(answer);
        }
    }
});


You are given an array $$$a$$$ consisting of $$$n$$$ integers.Your task is to determine if $$$a$$$ has some subsequence of length at least $$$3$$$ that is a palindrome.Recall that an array $$$b$$$ is called a subsequence of the array $$$a$$$ if $$$b$$$ can be obtained by removing some (possibly, zero) elements from $$$a$$$ (not necessarily consecutive) without changing the order of remaining elements. For example, $$$[2]$$$, $$$[1, 2, 1, 3]$$$ and $$$[2, 3]$$$ are subsequences of $$$[1, 2, 1, 3]$$$, but $$$[1, 1, 2]$$$ and $$$[4]$$$ are not.Also, recall that a palindrome is an array that reads the same backward as forward. In other words, the array $$$a$$$ of length $$$n$$$ is the palindrome if $$$a_i = a_{n - i - 1}$$$ for all $$$i$$$ from $$$1$$$ to $$$n$$$. For example, arrays $$$[1234]$$$, $$$[1, 2, 1]$$$, $$$[1, 3, 2, 2, 3, 1]$$$ and $$$[10, 100, 10]$$$ are palindromes, but arrays $$$[1, 2]$$$ and $$$[1, 2, 3, 1]$$$ are not.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 5000$$$) — the length of $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5000$$$ ($$$\sum n \le 5000$$$).

For each test case, print the answer — "YES" (without quotes) if $$$a$$$ has some subsequence of length at least $$$3$$$ that is a palindrome and "NO" otherwise.

NoteIn the first test case of the example, the array $$$a$$$ has a subsequence $$$[1, 2, 1]$$$ which is a palindrome.In the second test case of the example, the array $$$a$$$ has two subsequences of length $$$3$$$ which are palindromes: $$$[2, 3, 2]$$$ and $$$[2, 2, 2]$$$.In the third test case of the example, the array $$$a$$$ has no subsequences of length at least $$$3$$$ which are palindromes.In the fourth test case of the example, the array $$$a$$$ has one subsequence of length $$$4$$$ which is a palindrome: $$$[1, 2, 2, 1]$$$ (and has two subsequences of length $$$3$$$ which are palindromes: both are $$$[1, 2, 1]$$$).In the fifth test case of the example, the array $$$a$$$ has no subsequences of length at least $$$3$$$ which are palindromes.

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

let arr = ''
let ptr = 0
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main(arr)
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt(a) {
  return parseInt(a[ptr++])
}

function readString(a) {
  return a[ptr++]
}

function readStrings(a) {
  return a[ptr++].split(' ')
}

function readInts(a) {
  return a[ptr++].split(' ').map(a => parseInt(a))
}

function main(input) {
  let t = readInt(input)
  while(t--) {
    const n = readInt(input)
    const a = readInts(input)
    let ft = {}
    let lt = {}
    for(let i = 0; i < n; i++){
      if(!ft[a[i]]) {
        ft[a[i]] = i + 1
        lt[a[i]] = i + 1
      }
      else lt[a[i]] = i + 1
    }
    let f = false
    for(let i = 0; i < n && !f; i++){
      if(lt[a[i]]-ft[a[i]]>=2){
        f = true
      }
    }
    if(f) wr('YES')
    else wr('NO')
  }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8')
let inputString = '';
let currentLine = 0;
process.stdin.on('data', input => { inputString += input })
process.stdin.on('end', _ => { inputString = inputString.trim().split('\n').map(str => str.trim()); main() })
const readline = () => { return inputString[currentLine++] }

function main(){
	let tests = parseInt(readline());
	for(let i = 0; i < tests; i++){
		let num = parseInt(readline());
		let inputArr = readline().split(' ').map(x => parseInt(x));
		let mx = Math.max(...inputArr);
		let freq = new Array(mx + 1).fill(null).map(x => new Array(0));
		//for(let i = 0; i <= mx; i++) freq[i] = new Array(0);
		let yes = false;
		for(let j = 0; j < num; j++){
			let x = inputArr[j];
			freq[x].push(j);
			if(freq[x].length >= 2){
				let first = freq[x][0];
				let last = freq[x][freq[x].length - 1];
				if(last - first > 1){
					console.log("YES");
					yes = true;
					break;
				}
			}
		}
		if(!yes){
			console.log("NO");
		}
	}
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()
function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = getInts()

    let ok = false
    const freq = {}
    for (let i = 0; i < n; ++i) {
      if (Object.hasOwnProperty.call(freq, arr[i])) {
        if (i - freq[arr[i]] > 1) {
          ok = true
          break
        }
      } else {
        freq[arr[i]] = i
      }
    }
    print(ok ? 'YES' : 'NO')
  }
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = nextInt();
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var n = nextInt();
        var list = nextIntArray();
        var isOK = false;
        //odd
        for(var j = 1; j < n - 1; j++){
            var L = new Set();
            var R = new Set();
            for(var k = 0; k < j; k++){
                L.add(list[k]);
            }
            for(var k = j + 1; k < n; k++){
                if(L.has(list[k])){
                    isOK = true;
                    break;
                }
            }
        }

        if(isOK){
            output[i] = "YES";
        }else{
            output[i] = "NO";
        }
    }
    myout(myconv(output,9));
}

function isRotate(list){
    var len = list.length;
    var is = true;
    for(var i = 0; i < len; i++){
        if(list[i] != list[len - i - 1]){
            is = false;
        }
    }
    return is;
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var nums = readline().split(' ').map(Number);
  var map = {}
  var result = ''
  for (var i = 0; i < nums.length; i++) {
    var num = nums[i];
    if (!map[num]) map[num] = {count: 0, last: i}
    map[num].count++
    if (map[num].count > 2 || map[num].last + 1 < i) {
      result = 'YES'
      break
    }
    map[num].last = i
  }
  print(result || 'NO')
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()
function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = getInts()

    let ok = false
    const freq = {}
    for (let i = 0; i < n; ++i) {
      if (Object.hasOwnProperty.call(freq, arr[i])) {
        if (i - freq[arr[i]] > 1) {
          ok = true
          break
        }
      }
      freq[arr[i]] = i
    }
    print(ok ? 'YES' : 'NO')
  }
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = nextInt();
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var n = nextInt();
        var list = nextIntArray();
        var isOK = false;
        for(var j = 3; j <= 4; j++){//select chars(3~)
            if(isOK){
                break;
            }
            var tmp = new Array(j);
            for(var k = 0; k < j; k++){
                tmp[k] = list[k];
            }
            for(var k = 0; k < n - j + 1; k++){
                if(k != 0){
                    tmp.shift();
                    tmp.push(list[k + j]);
                }
                var ok = isRotate(tmp);
                if(ok){
                    isOK = true;
                    break;
                }
            }
        }
        if(isOK){
            output[i] = "YES";
        }else{
            output[i] = "NO";
        }
    }
    myout(myconv(output,9));
}

function isRotate(list){
    var len = list.length;
    var is = true;
    for(var i = 0; i < Math.ceil(len / 2); i++){
        if(list[i] != list[len - i - 1]){
            is = false;
        }
    }
    return is;
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = nextInt();
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var n = nextInt();
        var list = nextIntArray();
        var isOK = false;
        //odd
        for(var j = 1; j < n - 1; j++){
            var tmp = [list[j - 1], list[j], list[j + 1]];
            var ok = isRotate(tmp);
            if(ok){
                isOK = true;
                break;
            }
        }

        //even
        for(var j = 1; j < n - 2; j++){
            if(list[j] == list[j + 1]){
                var tmp = [list[j - 1], list[j], list[j + 1], list[j + 2]];
                var ok = isRotate(tmp);
                if(ok){
                    isOK = true;
                    break;
                }
            }
        }

        if(isOK){
            output[i] = "YES";
        }else{
            output[i] = "NO";
        }
    }
    myout(myconv(output,9));
}

function isRotate(list){
    var len = list.length;
    var is = true;
    for(var i = 0; i < Math.ceil(len / 2); i++){
        if(list[i] != list[len - i - 1]){
            is = false;
        }
    }
    return is;
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = nextInt();
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var n = nextInt();
        var list = nextIntArray();
        var isOK = false;
        //odd
        for(var j = 1; j < n - 1; j++){
            var tmp = [list[j - 1], list[j], list[j + 1]];
            var ok = isRotate(tmp);
            if(ok){
                isOK = true;
                break;
            }
        }

        //even
        for(var j = 1; j < n - 2; j++){
            if(list[j] == list[j + 1]){
                var tmp = [list[j - 1], list[j], list[j + 1], list[j + 2]];
                var ok = isRotate(tmp);
                if(ok){
                    isOK = true;
                    break;
                }
            }
        }

        if(isOK){
            output[i] = "YES";
        }else{
            output[i] = "NO";
        }
    }
    myout(myconv(output,9));
}

function isRotate(list){
    var len = list.length;
    var is = true;
    for(var i = 0; i < len; i++){
        if(list[i] != list[len - i - 1]){
            is = false;
        }
    }
    return is;
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = nextInt();
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var n = nextInt();
        var list = nextIntArray();
        var isOK = false;
        var tmp1 = [];
        for(var j = 0; j < n; j++){
            tmp1.push(list[j]);
            if(j >= 3){
                tmp1.shift();
            }
          if(j >= 2){
            var ok = isRotate(tmp1);
            if(ok){
                isOK = true;
                break;
            }
           }
        }

        var tmp2 = [];
        for(var j = 0; j < n; j++){
            tmp2.push(list[j]);
            if(j >= 4){
                tmp2.shift();
            }
          if(j >= 3){
            var ok = isRotate(tmp2);
            if(ok){
                isOK = true;
                break;
            }
           }
        }
        if(isOK){
            output[i] = "YES";
        }else{
            output[i] = "NO";
        }
    }
    myout(myconv(output,9));
}

function isRotate(list){
    var len = list.length;
    var is = true;
    for(var i = 0; i < Math.ceil(len / 2); i++){
        if(list[i] != list[len - i - 1]){
            is = false;
        }
    }
    return is;
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var str = readline().split(' ').join('');
  var pp = [];
  for(var i = 0; i < 9; i++) {
    for(var j = 0; j < 9; j++) {
      pp.push([i, j, i].join(''))
      pp.push([i, j, j, i].join(''))
    }
  }
  for(var i = 0; i < pp.length; i++) {
    if (str.indexOf(pp[i]) !== -1) {
      print('YES')
      break
    } else if (i == pp.length - 1) {
      print('NO')
    }
  }
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var str = readline().split(' ').join('');
  var pp = [];
  if (n < 3) {
    print('NO')
    break;
  }
  for(var i = 0; i <= 9; i++) {
    for(var j = 0; j <= 9; j++) {
      pp.push([i, j, i].join(''))
      pp.push([i, j, j, i].join(''))
    }
  }
  for(var i = 0; i < pp.length; i++) {
    if (str.indexOf(pp[i]) !== -1) {
      print('YES')
      break
    } else if (i === pp.length - 1) {
      print('NO')
    }
  }
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var str = readline().split(' ').join('');
  var pp = [];
  if (n < 2) {
    print('NO')
    break;
  }
  for(var i = 0; i < 9; i++) {
    for(var j = 0; j < 9; j++) {
      pp.push([i, j, i].join(''))
      pp.push([i, j, j, i].join(''))
    }
  }
  for(var i = 0; i < pp.length; i++) {
    if (str.indexOf(pp[i]) !== -1) {
      print('YES')
      break
    } else if (i === pp.length - 1) {
      print('NO')
    }
  }
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var nums = readline().split(' ').map(Number);
  var result = ''
  for (var i = 0; i < nums.length - 2; i++) {
    if ((nums[i] === nums[i + 2]) || (i < nums.length - 2 && nums[i] === nums[i + 3] && nums[i + 1] === nums[i + 2] )) {
      result = 'YES'
      break
    }
  }
  print(result || 'NO')
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var str = readline().split(' ').join('');
  var pp = [];
  if (n < 3) {
    print('NO')
    break;
  }
  for(var i = 0; i < 9; i++) {
    for(var j = 0; j < 9; j++) {
      pp.push([i, j, i].join(''))
      pp.push([i, j, j, i].join(''))
    }
  }
  for(var i = 0; i < pp.length; i++) {
    if (str.indexOf(pp[i]) !== -1) {
      print('YES')
      break
    } else if (i === pp.length - 1) {
      print('NO')
    }
  }
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var str = readline().split(' ').join('');
  var pp = [];
  if (n < 3) {
    print('NO')
    break;
  }
  for(var i = 0; i <= 9; i++) {
    for(var j = 0; j <= 9; j++) {
      pp.push([i, j, i].join(''))
      pp.push([i, j, j, i].join(''))
    }
  }
  var result = ''
  for(var i = 0; i < pp.length; i++) {
    if (str.indexOf(pp[i]) !== -1) {
      result = 'YES'
      break
    }
  }
  print(result || 'NO')
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var nums = readline().split(' ').map(Number);
  var map = {}
  var result = ''
  for (var i = 0; i < nums.length; i++) {
    var num = nums[i];
    if (!map[num]) map[num] = {count: 0, last: i}
    map[num].count++
    if (map[num] > 2 || map[num].last + 1 < i) {
      result = 'YES'
      break
    }
    map[num].last = i
  }
  print(result || 'NO')
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var nums = readline().split(' ').map(Number);
  var result = ''
  for (var i = 0; i < nums.length - 1; i++) {
    if ((nums[i] === nums[i + 2]) || (i < nums.length - 2 && nums[i] === nums[i + 3] && nums[i + 1] === nums[i + 2] )) {
      result = 'YES'
      break
    }
  }
  print(result || 'NO')
}


Given a positive integer $$$n$$$. Find three distinct positive integers $$$a$$$, $$$b$$$, $$$c$$$ such that $$$a + b + c = n$$$ and $$$\operatorname{gcd}(a, b) = c$$$, where $$$\operatorname{gcd}(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Description of the test cases follows. The first and only line of each test case contains a single integer $$$n$$$ ($$$10 \le n \le 10^9$$$).

For each test case, output three distinct positive integers $$$a$$$, $$$b$$$, $$$c$$$ satisfying the requirements. If there are multiple solutions, you can print any. We can show that an answer always exists.

NoteIn the first test case, $$$6 + 9 + 3 = 18$$$ and $$$\operatorname{gcd}(6, 9) = 3$$$.In the second test case, $$$21 + 39 + 3 = 63$$$ and $$$\operatorname{gcd}(21, 39) = 3$$$.In the third test case, $$$29 + 43 + 1 = 73$$$ and $$$\operatorname{gcd}(29, 43) = 1$$$.

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

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();
  });
  solve();
  // cmd: node solution.js < input.txt > output.txt
});
function readLine() {
  return inputString[currentLine++];
}

function solve() {
  let t = parseInt(readLine());
  while (t--) {
	let n = parseInt(readLine());
    problem(n);
  }
}
function gcd(i,j){
    if(j===0){
        return i;
    }
    return gcd(j,i%j);
}
function problem(n){
    n--;
    if(n%2!==0){
        console.log(`${parseInt(n/2)} ${parseInt((n+1)/2)} ${1}`);
    }else {
        let temp=n/2;
        for(let i=1;i<temp;i++){
            if(gcd(temp-i,temp+i)===1){
                console.log(`${temp-i} ${temp+i} ${1}`);
                break;
            }
        }
    }
}

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

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

let count = -1
let inputArr = []

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

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

    return gcd(b, a % b);
}

function solve(arr) {
    let b, s2 = Math.floor(arr / 2)
    for (let c = 1; c < arr; ++c) {
        for (let a = 0; a < s2; ++a) {
            b = arr - c - a;
            if (a === b || b === c || c === a) {
                continue
            }
            if (gcd(a, b) === c) {
                console.log(`${a} ${b} ${c}`)
                return
            }
        }
    }
}

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

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

    for (var t=0; t<tests;t++) {
        n = parseInt(readline());
        var ans;
        if (n & 1) {
            var mid = (n-1) / 2;
            if (mid & 1) {
                ans = [mid + 2, mid - 2, 1];
            } else {
                ans = [mid + 1, mid - 1, 1];
            }
        } else {
            ans = [n / 2, n / 2 - 1, 1];
        }
        print(ans.join(' '));
    }

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var n = lines[i];
        var a = new Map();
        for(j = 1; j * j <= n; j++){
            a.set(j * j, 1);
        }
        for(j = 1; j * j * j <= n; j++){
            a.set(j * j * j, 1);
        }
        console.log(a.size);
    }
});

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();
  });
  solve();
  // cmd: node solution.js < input.txt > output.txt
});
function readLine() {
  return inputString[currentLine++];
}

function solve() {
  let t = parseInt(readLine());
  while (t--) {
	let n = parseInt(readLine());
    GCDP(n);
  }
}
function GCDP(n){
    console.log(`${1} ${n-2} ${1}`);
}


Suppose you have two points $$$p = (x_p, y_p)$$$ and $$$q = (x_q, y_q)$$$. Let's denote the Manhattan distance between them as $$$d(p, q) = |x_p - x_q| + |y_p - y_q|$$$.Let's say that three points $$$p$$$, $$$q$$$, $$$r$$$ form a bad triple if $$$d(p, r) = d(p, q) + d(q, r)$$$.Let's say that an array $$$b_1, b_2, \dots, b_m$$$ is good if it is impossible to choose three distinct indices $$$i$$$, $$$j$$$, $$$k$$$ such that the points $$$(b_i, i)$$$, $$$(b_j, j)$$$ and $$$(b_k, k)$$$ form a bad triple.You are given an array $$$a_1, a_2, \dots, a_n$$$. Calculate the number of good subarrays of $$$a$$$. A subarray of the array $$$a$$$ is the array $$$a_l, a_{l + 1}, \dots, a_r$$$ for some $$$1 \le l \le r \le n$$$.Note that, according to the definition, subarrays of length $$$1$$$ and $$$2$$$ are good.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$). It's guaranteed that the sum of $$$n$$$ doesn't exceed $$$2 \cdot 10^5$$$.

For each test case, print the number of good subarrays of array $$$a$$$.

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 isgood (a, b, c) {
	const isbad = a >= b && b >= c || a <= b && b <= c;
	return !isbad;
}

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const a = rna();

		let ans = n + (n - 1);
		for (let i = 1; i < n; i++) {
			if (i-2 >= 0 && isgood(a[i], a[i-1], a[i-2])) {
				ans++;
				if (i-3 >= 0) {
					let ok = isgood(a[i], a[i-1], a[i-3]);
					ok &= isgood(a[i], a[i-2], a[i-3]);
					ok &= isgood(a[i-1], a[i-2], a[i-3]);
					ans += ok;
				}
			}
		}

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

function isBad (a, b, c) {
	x = a >= b && b >= c || a <= b && b <= c;
	return x;
}

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const a = rna();

		let ans = 1;
		for (let i = 1; i < n; i++) {
			ans += 2;
			if (i-2 >= 0 && !isBad(a[i], a[i-1], a[i-2])) {
				ans++;
				if (i-3 >= 0 && !isBad(a[i], a[i-1], a[i-3]) && !isBad(a[i], a[i-2], a[i-3])) {
					ans++;
				}
			}
		}

		console.log(ans);
	}
}


YouKn0wWho has an integer sequence $$$a_1, a_2, \ldots a_n$$$. Now he will split the sequence $$$a$$$ into one or more consecutive subarrays so that each element of $$$a$$$ belongs to exactly one subarray. Let $$$k$$$ be the number of resulting subarrays, and $$$h_1, h_2, \ldots, h_k$$$ be the lengths of the longest increasing subsequences of corresponding subarrays.For example, if we split $$$[2, 5, 3, 1, 4, 3, 2, 2, 5, 1]$$$ into $$$[2, 5, 3, 1, 4]$$$, $$$[3, 2, 2, 5]$$$, $$$[1]$$$, then $$$h = [3, 2, 1]$$$.YouKn0wWho wonders if it is possible to split the sequence $$$a$$$ in such a way that the bitwise XOR of $$$h_1, h_2, \ldots, h_k$$$ is equal to $$$0$$$. You have to tell whether it is possible.The longest increasing subsequence (LIS) of a sequence $$$b_1, b_2, \ldots, b_m$$$ is the longest sequence of valid indices $$$i_1, i_2, \ldots, i_k$$$ such that $$$i_1 \lt i_2 \lt \ldots \lt i_k$$$ and $$$b_{i_1} \lt b_{i_2} \lt \ldots \lt b_{i_k}$$$. For example, the LIS of $$$[2, 5, 3, 3, 5]$$$ is $$$[2, 3, 5]$$$, which has length $$$3$$$.An array $$$c$$$ is a subarray of an array $$$b$$$ if $$$c$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10\,000$$$)  — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$). The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

For each test case, print "YES" (without quotes) if it is possible to split into subarrays in the desired way, print "NO" (without quotes) otherwise. You can print each letter in any register (upper or lower).

NoteIn the first test case, YouKn0wWho can split the sequence in the following way: $$$[1, 3, 4]$$$, $$$[2, 2]$$$, $$$[1, 5]$$$. This way, the LIS lengths are $$$h = [3, 1, 2]$$$, and the bitwise XOR of the LIS lengths is $$$3 \oplus 1 \oplus 2 = 0$$$.In the second test case, it can be shown that it is impossible to split the sequence into subarrays that will satisfy the condition.

const solve = (n,arr)=>{
     if(n%2===0) console.log("YES");
     else{
          for(let i=0;i<n-1;i++){
               if(arr[i]>=arr[i+1]){
                    console.log("YES");
                    return;
               }
          }
          console.log("NO");
     }
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let n = parseInt(readline());
       let arr =  readline().trim().split(" ").map(cur=>parseInt(cur));
       solve(n,arr);
  }
}
main();

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

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

let count = -1
let inputArr = []

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

function solve([n], arr) {
    let res = true
    if (n % 2) {
        res = false
        for (let j = 1; j < n; j++) {
            if (arr[j] <= arr[j - 1]) {
                res = true
                break;
            }
        }
    }
    if (res) {
        console.log("YES")
    } else {
        console.log("NO")
    }
}

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

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 n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    if (!(n & 1)) return 'YES'

    for (let i = 1; i < arr.length; i++) {
        if (arr[i] <= arr[i - 1]) {
            return 'YES'
        }
    }
    return 'NO'
}

//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] = BigInt(next());
		}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 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 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 list = nextIntArray(N);
		var isOK = (N % 2 == 0);
		for(var i = 0; i < N - 1; i++){
			if(list[i] >= list[i + 1]){
				isOK = true;
				break;
			}
		}
		if(isOK){
			myout("Yes");
		}else{
			myout("No");
		}
	}
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let curLine = 0;

function readLine() {
  return standardInputString[curLine++];
}

process.stdin.on("data", rawData => {
  standardInputString += rawData;
});

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

  main();
});

// Codeforces Round #752 (Div. 2)

// B

const main = () => {
  const t = +readLine();

  for (let testCaseNum = 0; testCaseNum < t; testCaseNum += 1) {
    const sequenceLen = +readLine();

    const sequence = readLine()
      .split(' ')
      .map(str => +str);

    let xorIsZero = sequenceLen % 2 === 0;

    for (let ix = 1; ix < sequenceLen; ix += 1) {
      xorIsZero = xorIsZero || sequence[ix] <= sequence[ix - 1];
    }

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

const solve = (n,arr)=>{
     if(n%2===0) console.log("YES");
     else{
          let obj = {};
          for(let i=0;i<n;i++){
               if(obj[arr[i]]){
                    console.log("YES");
                    return;
               }
               obj[arr[i]] = true;
          }
          console.log("NO");
     }
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let n = parseInt(readline());
       let arr =  readline().trim().split(" ").map(cur=>parseInt(cur));
       solve(n,arr);
  }
}
main();

const solve = (n,arr)=>{
     if(n%2===0) console.log("YES");
     else{
          let obj = {};
          for(let i=0;i<n;i++){
               if(obj[arr[i]]){
                    console.log("YES");
                    return;
               }
               obj[arr[i]] = 1;
          }
          console.log("NO");
     }
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let n = parseInt(readline());
       let arr =  readline().trim().split("").map(cur=>parseInt(cur));
       solve(n,arr);
  }
}
main();

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

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

let count = -1
let inputArr = []

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

function solve([n], arr) {
    let res = true
    if (n % 2 !== 0) {
        res = false;
        for (let j = 1; j < n; ++j) {
            if (arr[j] <= arr[j - 1]) {
                res = true
                break
            }
        }
    }
    if (res) {
        console.log("YES")
    } else {
        console.log("NO")
    }
}

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

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 n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    if (!(n & 1)) return 'YES'

    for (let i = 2; i < arr.length; i++) {
        if (arr[i] < arr[i - 1]) {
            return 'YES'
        }
    }
    return '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 n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    if (!(n & 1)) return 'YES'

    for (let i = 2; i < arr.length; i++) {
        if (arr[i] <= arr[i - 1]) {
            return 'YES'
        }
    }
    return 'NO'
}