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 j = 1; j <= n; j++){
        var k = lines[j];
        console.log(2 + ' ' + (k - 1));
    }
});

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 p = nl.num();
		ans.push([2, p-1]);
	}
	console.log(ans.map(e => e.join(' ')).join('\n'));
};

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

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function writeOutput(s) {
  process.stdout.write(s);
}

function main() {
  let t = parseInt(readline(), 10);
  while(t--) {
    let n = parseInt(readline(), 10);
    for (let i = 0; i*i < n; ++i) {
      let found = false;
      for (let a = Math.max(2, i+1); a*a < n; ++a) {
        if ((n-i) % a === 0 && (n-i) != a) {
          writeOutput(`${a} ${(n-i)}\n`);
          found = true;
          break;
        }
      }
      if (found) break;
    }
  }
}

// run: cat input.txt | node A.js

var fs = require("fs");
var stdinBuffer = fs.readFileSync(0); // STDIN_FILENO = 0

const lines = stdinBuffer.toString().match(/[^\r\n]+/g).slice(1);

const examples = [];

for(let i = 0; i < lines.length; i++) {
    examples.push(parseInt(lines[i], 10));
}

const solver = (n) => {
    return 2 + " " + (n-1).toString()
};

for(let example of examples) {
    console.log(solver(example))
}

'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 = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
  var a = parseInt(readline());
  // var [n, m] = readline().split(' ').map((x, iii) => {
  //     return parseInt(x)
  //   })
    var answe = 2
    console.log(2, a-1)
  })
  // var res = new Array(n)
}

function plus(a, b, res) {
// console.log(a, b, res)
  if (a === 0) return res

  return plus(a < 0 ? a + 1 : a - 1, b, a < 0 ? res - b : res + b)
}

//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 P = nextInt();
		var L = 2;
		var R = (P - 1);
		myout(L + " " + R);
	}
}

"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() {
  let t;
t = parseInt(readline());
while (t--) {
  let n = parseInt(readline());
  console.log(2 + " " + (n - 1) );
}

}

const nextString = (function() {
  const listeners = [], strings = [], ps = process.stdin
  let last = ''
  ps.setEncoding('utf8')
  ps.on('readable', () => {
    let chunk
    while ((chunk = ps.read()) !== null) {
      chunk = (last + chunk).split(/\r\n|\r|\n/)
      last = chunk[chunk.length - 1]
      for (let i = 0; i < chunk.length - 1; ++i) {
        if (chunk[i].length > 0) {
          if (listeners.length > 0) {
            listeners.shift()(chunk[i])
          }
          else {
            strings.push(chunk[i])
          }
        }
      }
    }
  })
  const fn = resolve => {
    if (strings.length > 0) {
      resolve(strings.shift())
    }
    else {
      listeners.push(resolve)
    }
  }
  return () => new Promise(fn)
})()

function extend(mas) {
  let n = mas.length
  mas.unshift(new Array(n++).fill('.'))
  for (let i = 0; i < n; ++i) {
    mas[i].push('.')
  }
}

async function main() {
  let n = +await nextString()
  for (let i = 0; i < n; ++i) {
    let p = +await nextString()
    console.log(`2 ${p - 1}`)
  }
}

main()

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const assert = (condition) => { if (!condition) throw new Error("Assertion failed"); }
const mi = Math.min;
const mx = Math.max;
const mxll = (...args) => args.reduce((m, e) => e > m ? e : m);
const mill = (...args) => args.reduce((m, e) => e < m ? e : m);
const sqll = (v) => { if (v < 0n) throw 'negative input'; if (v < 2n) return v; const dfs = (n, x0) => { let x1 = ((n / x0) + x0) >> 1n; if (x0 === x1 || x0 === (x1 - 1n)) return x0; return dfs(n, x1); }; return dfs(v, 1n); }; // has >> 0
const abs = Math.abs;
const fl = Math.floor;
const int = parseInt;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg2 = Math.log2;
const lg10 = Math.log10;
const ll = BigInt;
const combination = (m, n) => { return factorial(m, n) / factorial(n, n); };
const factorial = (m, n) => { let num = 1n; let cnt = 0; for (let i = ll(m); i > 0; i--) { if (cnt == n) break; num *= i; cnt++; } return num; };
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const bitCount = (n) => { n = n - ((n >> 1) & 0x55555555); n = (n & 0x33333333) + ((n >> 2) & 0x33333333); return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; };
const powmod = (a, b, mod) => { let r = 1n; while (b > 0n) { if (b % 2n == 1) r = r * a % mod; b >>= 1n; a = a * a % mod; } return r; };
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const sortPart = (a, k) => { let l = a.slice(0, k); l.sort((x, y) => x - y); let r = a.slice(k); return l.concat(r); }; // sort first kth
const initialize2DArrayNew = (n, m) => { let data = []; for (let i = 0; i < n; i++) { let tmp = Array(m).fill(0); data.push(tmp); } return data; };
const initialize3DArray = (n, m, p) => { let res = []; for (let i = 0; i < n; i++) { let data = []; for (let j = 0; j < m; j++) { let tmp = new Array(p).fill(0); data.push(tmp); } res.push(data); } return res; };
const stmkey_in = (m) => new Map([...m].sort((x, y) => x[0] - y[0]));
const stmkey_de = (m) => new Map([...m].sort((x, y) => y[0] - x[0]));
const stmvalue_in = (m) => new Map([...m].sort((x, y) => x[1] - y[1]));
const stmvalue_de = (m) => new Map([...m].sort((x, y) => y[1] - x[1]));
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
const counter_value_in_indexA_in = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).push(i); } return m; };
const counter_value_in_indexA_de = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).unshift(i); } return m; };
const reverse2 = (s) => { let res = ""; for (let i = s.length - 1; i >= 0; i--) { res += s[i]; } return res; };
const isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };
const ups = (s, i, c) => s.slice(0, i) + c + s.slice(i + 1);
const isSubsequence = (s, t) => { let sn = s.length; let tn = t.length; let i = j = 0; while (i < sn && j < tn) { if (s[i] == t[j]) { i++; j++; } else { i++; } } return j == tn; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * 08/01/21 evening
 * https://codeforces.com/contest/1549/problem/A
 */
const solve = (p) => {
    pr(2, p - 1);
};

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

main()

let i = ''
let lines
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  lines = i.split('\n') // your input text, split by lines
  main()
})

function main() {
  let t = parseInt(lines.shift())

  while (t > 0) {
    const p = parseInt(lines.shift())

    if (p === 5) {
      console.log(2, 4)
    } else {
      console.log(2, (p - 1) / 2)
    }
    t--
  }
}

function solve(p) {
  if (p === 5) return [2, 4];
  return [2, parseInt(p / 2)];
}

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
  p = parseInt(readline());
  var ans = solve(p);
  print(ans[0], ans[1]);
}

n = readline();
while(n--) {
  s = readline();
  print(2, s-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];
    for(var j = 1; j <= n[0]; j++){
        var k = lines[j];
        console.log(2 + ' ' + (k - 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];
    for(var j = 1; j <= n[0]; j++){
        var k = lines[j];

    }
    console.log(3 + ' ' + 5 + "\n" + 2 + ' ' + 4);
});

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

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

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function writeOutput(s) {
  process.stdout.write(s);
}

function main() {
  let t = parseInt(readline(), 10);
  while(t--) {
    let n = parseInt(readline(), 10);
    for (let i = 1; i*i < n; ++i) {
      let found = false;
      for (let a = i+1; a*a < n; ++a) {
        if ((n-i) % a === 0 && (n-i) / a != a) {
          writeOutput(`${a} ${(n-i)/a}\n`);
          found = true;
          break;
        }
      }
      if (found) break;
    }
  }
}

// run: cat input.txt | node A.js

var fs = require("fs");
var stdinBuffer = fs.readFileSync(0); // STDIN_FILENO = 0

const lines = stdinBuffer.toString().match(/[^\r\n]+/g).slice(1);

const examples = [];

for(let i = 0; i < lines.length; i++) {
    examples.push(parseInt(lines[i], 10));
}

const solver = (n) => {
    return 2 + " " + (n-1).toString()
};

for(let example of examples) {
    console.log(solver(example).length)
}

'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 = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
  var a = parseInt(readline());
  // var [n, m] = readline().split(' ').map((x, iii) => {
  //     return parseInt(x)
  //   })
    var answe = 2
    for (let j = 2; j < 100; j++) {
      if(a %j === 1) answe = j
    }
    console.log(2, answe)
  // var a = readline().split(' ').map((x, iii) => {
  //   return parseInt(x)
  })
  // var res = new Array(n)
}

function plus(a, b, res) {
// console.log(a, b, res)
  if (a === 0) return res

  return plus(a < 0 ? a + 1 : a - 1, b, a < 0 ? res - b : res + b)
}

function solve(p) {
  if (p === 5) return [2, 3];
  return [2, parseInt(p / 2)];
}

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
  p = parseInt(readline());
  var ans = solve(p);
  print(ans[0]+" "+ans[1]);
}

function solve(p) {
  if (p === 5) return [2, 3];
  var i = 2;

  while (true) {
    var a = i;
    var b = parseInt(p / i);
    if (a !== b && Math.max(a, b) <= p) return [Math.min(a, b), Math.max(a, b)];
    i++;
  }
}

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
  p = parseInt(readline());
  var ans = solve(p);
  print(ans[0], ans[1]);
}

function solve(p) {
  if (p === 5) return [2, 3];
  var i = 2;

  while (true) {
    var a = i;
    var b = parseInt(p / i);
    if (Math.max(a, b) <= p) return [Math.min(a, b), Math.max(a, b)];
    i++;
  }
}

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
  p = parseInt(readline());
  var ans = solve(p);
  print(ans[0], ans[1]);
}

function solve(p) {
  if (p === 5) return [2, 3];
  return [2, parseInt(p / 2)];
}

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
  p = parseInt(readline());
  var ans = solve(p);
  print(ans[0], ans[1]);
}


var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var S = one[1];
	if(N == 1){
		if(S == 1){
			myout("NO");
		}else{
			myout("YES");
			myout(S);
			myout(S - 1);
		}
		return;
	}
	var list = new Array(N);
	var oneCount = 0;
	for(var i = 0; i < N; i++){
		if(i == N - 1){
			list[i] = S;
		}else{
			list[i] = 1;
			oneCount++;
			S--;
		}
	}
	myerr(oneCount);
	if(oneCount < S - 1){
		myout("YES");
		myout(myconv(list,8));
		myout(S - 1);
	}else{
		myout("NO");
	}
}

const processData = (lines) => {
  const [n, s] = lines[0].split(' ').map(x => +x)
  if (n*2 > s) {
    console.log('NO')
  } else {
    console.log('YES')
    let t = s
    const res = []
    for (let i=0; i<n-1; i++) {
      res.push(2)
      t-= 2
    }
    res.push(t)
    console.log(res.join(' '))
    console.log(1)
  }
}

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

var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var S = one[1];
	if(N == 1){
		if(S == 1){
			myout("NO");
		}else{
			myout("YES");
			myout(S);
			myout(S - 1);
		}
		return;
	}
	var list = new Array(N);
	var oneCount = 0;
	for(var i = 0; i < N; i++){
		if(i == N - 1){
			list[i] = S;
		}else{
			list[i] = 1;
			oneCount++;
			S--;
		}
	}
	myerr(oneCount);
	if(oneCount < S){
		myout("YES");
		myout(myconv(list,8));
		myout(S - 1);
	}else{
		myout("NO");
	}
}

var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var S = one[1];
	if(N == 1){
		if(S == 1){
			myout("NO");
		}else{
			myout("YES");
			myout(S);
			myout(S - 1);
		}
	}
	var list = new Array(N);
	var oneCount = 0;
	for(var i = 0; i < N; i++){
		if(i == N - 1){
			list[i] = S;
		}else{
			list[i] = 1;
			oneCount++;
			S--;
		}
	}
	myerr(oneCount);
	if(oneCount < S){
		myout("YES");
		myout(myconv(list,8));
		myout(S - 1);
	}else{
		myout("NO");
	}
}


function For(a, b, step, fn) {
  let res;
  if (step > 0) {
    for (let i = a; i <= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  } else {
    for (let i = a; i >= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  }
}

function Arr(a, b, step, fn, init) {
  if (!step) {
    return a < b
      ? Array(b - a + 1).fill(0).map((v, i) => fn(a + i))
      : Array(a - b + 1).fill(0).map((v, i) => fn(a - i))
  }
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  if (step > 0) for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  else for (let i = a; i >= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n)
    let c = Arr(0, n, 1, i => []);
    For(0, n - 1, 1, i => { c[a[i]].push(i) });
    // log(c);
    let res = Array(n + 1).fill(-1);
    let k = n;
    For(1, n, 1, i => {
      if (!c[i].length) return;
      c[i].push(n);
      let maxk = c[i].map((v, i, a) => i == 0 ? v : v - 1 - a[i - 1]).max()[0];
      while (k > 0 && k > maxk) res[k--] = i;
    })
    log(res.slice(1).join(' '))
  }
}

function For(a, b, step, fn) {
  let res;
  if (step > 0) {
    for (let i = a; i <= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  } else {
    for (let i = a; i >= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  }
}

function Arr(a, b, step, fn, init) {
  if (!step) {
    return a < b
      ? Array(b - a + 1).fill(0).map((v, i) => fn(a + i))
      : Array(a - b + 1).fill(0).map((v, i) => fn(a - i))
  }
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  if (step > 0) for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  else for (let i = a; i >= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n)
    let c = Arr(0, n, 1, i => [-1]);
    For(0, n - 1, 1, i => { c[a[i]].push(i) });
    // log(c);
    let res = Array(n + 1).fill(-1);
    let k = n;
    For(1, n, 1, i => {
      if (c[i].length <= 1) return;
      c[i].push(n)
      // let maxk = Arr(1,c[i].length-1,1,j=>c[i][j]-1-c[i][j-1]).max()[0]
      // log(i,maxk);
      let maxk = 0;
      for (let j = 1; j < c[i].length; j++) maxk = max(maxk, c[i][j] - 1 - c[i][j - 1])
      while (k > 0 && k > maxk) res[k--] = i;
    })
    log(res.slice(1).join(' '))
  }
}

function For(a, b, step, fn) {
  let res;
  if (step > 0) {
    for (let i = a; i <= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  } else {
    for (let i = a; i >= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  }
}

function Arr(a, b, step, fn, init) {
  if (!step) {
    return a < b
      ? Array(b - a + 1).fill(0).map((v, i) => fn(a + i))
      : Array(a - b + 1).fill(0).map((v, i) => fn(a - i))
  }
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  if (step > 0) for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  else for (let i = a; i >= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n)
    let c = Arr(0, n, 1, i => []);
    For(0, n - 1, 1, i => {
      c[a[i]].push(i);
    });
    // log(c);
    let res = Array(n + 1).fill(-1);
    let k = n;
    For(1, n, 1, i => {
      if (!c[i].length) return;
      let maxk = max(c[i][0], n - 1 - c[i][c[i].length - 1]);
      for (let j = 1; j < c[i].length; j++) maxk = max(maxk, c[i][j] - 1 - c[i][j - 1]);
      while (k > 0 && k > maxk) res[k--] = i;
    })
    log(res.slice(1).join(' '))
  }
}

function For(a, b, step, fn) {
  let res;
  if (step > 0) {
    for (let i = a; i <= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  } else {
    for (let i = a; i >= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  }
}

function Arr(a, b, step, fn, init) {
  if (!step) {
    return a < b
      ? Array(b - a + 1).fill(0).map((v, i) => fn(a + i))
      : Array(a - b + 1).fill(0).map((v, i) => fn(a - i))
  }
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  if (step > 0) for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  else for (let i = a; i >= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n)
    let c = Arr(0, n, 1, i => [-1]);
    For(0, n - 1, 1, i => { c[a[i]].push(i) });
    // log(c);
    let res = Array(n + 1).fill(-1);
    let k = n;
    For(1, n, 1, i => {
      if (c[i].length <= 1) return;
      c[i].push(n)
      let maxk = Arr(1, c[i].length - 1, 0, j => c[i][j] - 1 - c[i][j - 1]).max()[0]
      // let maxk = 0;
      // for (let j = 0; j < a.length; j++) maxk = max(maxk, a[j])
      while (k > 0 && k > maxk) res[k--] = i;
    })
    log(res.slice(1).join(' '))
  }
}

function For(a, b, step, fn) {
  let res;
  if (step > 0) {
    for (let i = a; i <= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  } else {
    for (let i = a; i >= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  }
}

function Arr(a, b, step, fn, init) {
  if (!step) {
    return a < b
      ? Array(b - a + 1).fill(0).map((v, i) => fn(a + i))
      : Array(a - b + 1).fill(0).map((v, i) => fn(a - i))
  }
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  if (step > 0) for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  else for (let i = a; i >= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n)
    let c = Arr(0, n, 1, i => [-1]);
    For(0, n - 1, 1, i => { c[a[i]].push(i) });
    // log(c);
    let res = Array(n + 1).fill(-1);
    let k = n;
    For(1, n, 1, i => {
      if (c[i].length <= 1) return;
      c[i].push(n)
      let a = Arr(1, c[i].length - 1, 1, j => c[i][j] - 1 - c[i][j - 1])
      let maxk = 0;
      for (let j = 0; j < a.length; j++) maxk = max(maxk, a[j])
      while (k > 0 && k > maxk) res[k--] = i;
    })
    log(res.slice(1).join(' '))
  }
}

'use strict';

var readline = require('readline');

function tTwoLinesPerStdin() {
  return new Promise(resolve => {
    const stdin = readline.createInterface(process.stdin);
    let t;
    let prevLine;
    let output = [];
    stdin.on('line', line => {
      if (typeof t !== 'number') {
        t = +line;
      } else {
        if (prevLine) {
          output.push([prevLine, line]);
          prevLine = undefined;

          if (output.length === t) {
            resolve(output);
            stdin.close();
          }
        } else {
          prevLine = line;
        }
      }
    });
  });
}

function solve(nums) {
  const track = new Map();

  for (let i = 0; i < nums.length; i++) {
    const element = nums[i];
    const t = track.get(element) || {
      maxSpace: 0,
      lastIndex: -1
    };
    const space = i - t.lastIndex;

    if (space > t.maxSpace) {
      t.maxSpace = space;
    }

    t.lastIndex = i;
    track.set(element, t);
  }

  for (const t of track.values()) {
    const space = nums.length - t.lastIndex;

    if (space > t.maxSpace) {
      t.maxSpace = space;
    }
  }

  const answerPrep = [];

  for (const [num, t] of track) {
    if (!answerPrep[t.maxSpace] || answerPrep[t.maxSpace] > num) {
      answerPrep[t.maxSpace] = num;
    }
  }

  const answer = [];
  let lastAnswer = -1;

  for (let i = 1; i <= nums.length; i++) {
    const element = answerPrep[i];

    if (element !== undefined && (lastAnswer === -1 || element < lastAnswer)) {
      lastAnswer = element;
    }

    answer.push(lastAnswer);
  }

  return answer;
}

async function main() {
  const input = await tTwoLinesPerStdin();

  for (let t = 0; t < input.length; t++) {
    const [line2] = input[t].slice(1);
    const answer = solve(line2.split(' ').map(Number));
    console.log(answer.join(' '));
  }
}

main().then();

function For(a, b, step, fn) {
  let res;
  if (step > 0) {
    for (let i = a; i <= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  } else {
    for (let i = a; i >= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  }
}

function Arr(a, b, step, fn, init) {
  if (!step) {
    return a < b
      ? Array(b - a + 1).fill(0).map((v, i) => fn(a + i))
      : Array(a - b + 1).fill(0).map((v, i) => fn(a - i))
  }
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  if (step > 0) for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  else for (let i = a; i >= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n)
    let c = Arr(0, n, 1, i => []);
    For(0, n - 1, 1, i => {
      c[a[i]].push(i);
    });
    // log(c);
    let res = Array(n + 1).fill(-1);
    let k = n;
    For(1, n, 1, i => {
      if (!c[i].length) return;
      let maxk = c[i].map((v, i) => i == 0 ? v : v - a[i - 1] - 1).max()[0];
      maxk = max(maxk, n - 1 - c[i][c[i].length - 1]);
      // log(i,maxk);
      while (k > 0 && k > maxk) res[k--] = i;
    })
    log(res.slice(1).join(' '))
  }
}

function For(a, b, step, fn) {
  let res;
  if (step > 0) {
    for (let i = a; i <= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  } else {
    for (let i = a; i >= b; i += step) {
      if ((res = fn(i)) != null) return res;
    }
  }
}

function Arr(a, b, step, fn, init) {
  if (!step) {
    return a < b
      ? Array(b - a + 1).fill(0).map((v, i) => fn(a + i))
      : Array(a - b + 1).fill(0).map((v, i) => fn(a - i))
  }
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  if (step > 0) for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  else for (let i = a; i >= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n)
    // let l = Array(n)
    // let r = Array(n)
    // l[0] = -1
    // For(1, n - 1, 1, i => {
    //   l[i] = i - 1;
    //   while (l[i] >= 0 && a[l[i]] >= a[i]) l[i] = l[l[i]];
    // })
    // r[n - 1] = n;
    // For(n - 2, 0, -1, i => {
    //   r[i] = i + 1;
    //   while (r[i] < n && a[r[i]] >= a[i]) r[i] = r[r[i]];
    // });
    let c = Arr(0, n, 1, i => []);
    For(0, n - 1, 1, i => {
      c[a[i]].push(i);
    });
    // log(c);
    let res = Array(n + 1).fill(-1);
    let k = n;
    For(1, n, 1, i => {
      if (!c[i].length) return;
      let maxk = c[i].map((v, i) => i == 0 ? v : v - a[i - 1]).max()[0];
      maxk = max(maxk, n - 1 - c[i][c[i].length - 1]);
      // log(i,maxk);
      while (k > 0 && k > maxk) res[k--] = i;
    })
    log(res.slice(1).join(' '))
  }
}


'use strict'
var os = require('os')
function createInput(n) {
  const t = n.stdin || process.stdin,
    e = /-?\d+/g,
    r = /-?\d+(?:\.\d+)?/g
  let u = [],
    i = 0
  return {
    init: async function () {
      const n = []
      ;(u = await new Promise(e => {
        t.on('data', t => n.push(t)),
          t.on('end', function () {
            const t = n.join('').split(os.EOL)
            e(t)
          })
      })),
        (i = 0)
    },
    dried: function () {
      return i >= u.length
    },
    readLine: o,
    readLineAsNumber: function () {
      return Number(o())
    },
    readIntegersOfLine: function () {
      const n = o().match(e)
      return null == n ? [] : n.map(n => Number(n))
    },
    readNumsOfLine: function () {
      const n = o().match(r)
      return null == n ? [] : n.map(n => Number(n))
    },
  }
  function o() {
    return u[i++]
  }
}
function createOutput(n) {
  const t = n.stdout || process.stdout,
    e = n.encoding || 'ascii',
    r = n.outputBufferThreshold || 1 << 24,
    u = r >> 1,
    i = Buffer.alloc(r)
  let o = 0
  return {
    flush: s,
    print: function (n) {
      c('string' == typeof n ? n : n.toString())
    },
    println: function (n) {
      c(('string' == typeof n ? n : n.toString()).concat('\n'))
    },
  }
  function s() {
    t.write(i.toString(e, 0, o)), (o = 0)
  }
  function c(n) {
    const c = Buffer.byteLength(n, e)
    r - o < c && (s(), c > u) ? t.write(n) : (i.write(n, o, e), (o += c))
  }
}
function createInputAndOutput(n) {
  return {
    ...createInput({ stdin: n.stdin, encoding: n.encoding }),
    ...createOutput({
      stdout: n.stdout,
      encoding: n.encoding,
      outputBufferThreshold: n.outputBufferThreshold,
    }),
  }
}
async function __main__(n, t, e = {}) {
  const r = createInputAndOutput(e)
  await Promise.all([r.init(), Promise.resolve(t && t())]),
    await n(r),
    r.flush()
}
__main__(function (n) {
  const t = n.readLineAsNumber()
  for (let r = 1; r <= t; ++r) {
    const [t, r] = n.readIntegersOfLine(),
      u = e(t, r)
    n.println(u)
  }
  function e(n, t) {
    return 1 & Math.abs(n - t) ? -1 : n === t ? (0 === n ? 0 : 1) : 2
  }
})

//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 c = nextInt();
		var d = nextInt();
		if(Math.abs(c - d) % 2 == 1){
			myout(-1);
		}else if(Math.abs(c - d) == 0){
			if(c == 0 && d == 0){
				myout(0);
			}else{
				myout(1);
			}
		}else{
			myout(2);
		}
	}
}

//Vismillahir Rahmanir Rahim (Allah hu Ackbar);

"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 = Number(readline());
    var ans = 0;
    while (t--) {

        var arr = readline().split(' ').map(x => parseInt(x));
        var a = arr[0],
            b = arr[1];

        if ((a + b) % 2 != 0) {
            ans = -1;
        } else if ((a + b == 0)) {
            ans = 0
        } else if (a == b) {
            ans = 1;
        } else {
            ans = 2;
        }
        console.log(ans);

    }
}

//Vismillahir Rahmanir Rahim (Allah hu Ackbar);

// var t = Number(readline());
// var ans = 0;
// var k0 = 0;
// var k01 = 0;
// while (t--) {
//     var arr = readline().split(' ').map(x => parseInt(x));
//     var a = arr[0],
//         b = arr[1];
//     if (a > b) {
//         var temp = b;
//         b = a;
//         a = temp;
//     }
//     for (var i = 0; i <= 10000; i++) {
//         if (a < i) {
//             k0 = i - a;
//         } else {
//             k0 = a - i;
//         }
//         if (b < i) {
//             k01 = i - b;
//         } else {
//             k01 = b - i;
//         }
//         var k1 = a + i;
//         var k11 = b + i;
//         var k2 = a + i;
//         var k22 = k01;
//         var k3 = k0;
//         var k33 = b + i
//         if (a == 0 && b == 0) {
//             ans = 0;
//             break;
//         } else if (k1 == k11) {

//             ans = 1;
//             break;
//         } else if (k2 == k22) {
//             // console.log(k2 + " " + k22);
//             ans = 2;
//             break;
//         } else if (k3 == k33) {
//             ans = 3
//                 // console.log(k3 + " " + k33);
//             break;
//         } else {
//             ans = -1;
//         }
//     }
//     console.log(ans);

// }

"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 = Number(readline());
    var ans = 0;
    var k0 = 0;
    var k01 = 0;
    while (t--) {
        var arr = readline().split(' ').map(x => parseInt(x));
        var a = arr[0],
            b = arr[1];
        if (a > b) {
            var temp = b;
            b = a;
            a = temp;
        }
        for (var i = 0; i <= 10000; i++) {
            if (a < i) {
                k0 = i - a;
            } else {
                k0 = a - i;
            }
            if (b < i) {
                k01 = i - b;
            } else {
                k01 = b - i;
            }
            var k1 = a + i;
            var k11 = b + i;
            var k2 = a + i;
            var k22 = k01;
            var k3 = k0;
            var k33 = b + i
            if (a == 0 && b == 0) {
                ans = 0;
                break;
            } else if (k1 == k11) {

                ans = 1;
                break;
            } else if (k2 == k22) {
                // console.log(k2 + " " + k22);
                ans = 2;
                break;
            } else if (k3 == k33) {
                ans = 3
                    // console.log(k3 + " " + k33);
                break;
            } else {
                ans = -1;
            }
        }
        console.log(ans);

    }

}

//Vismillahir Rahmanir Rahim (Allah hu Ackbar);

// var t = Number(readline());
// var ans = 0;
// var k0 = 0;
// var k01 = 0;
// while (t--) {
//     var arr = readline().split(' ').map(x => parseInt(x));
//     var a = arr[0],
//         b = arr[1];
//     if (a > b) {
//         var temp = b;
//         b = a;
//         a = temp;
//     }
//     for (var i = 0; i < 1000000; i++) {
//         if (a < i) {
//             k0 = i - a;
//         } else {
//             k0 = a - i;
//         }
//         if (b < i) {
//             k01 = i - b;
//         } else {
//             k01 = b - i;
//         }
//         var k1 = a + i;
//         var k11 = b + i;
//         var k2 = a + i;
//         var k22 = k01;
//         var k3 = k0;
//         var k33 = b + i
//         if (a == 0 && b == 0) {
//             ans = 0;
//             break;
//         } else if (k1 == k11) {

//             ans = 1;
//             break;
//         } else if (k2 == k22) {
//             // console.log(k2 + " " + k22);
//             ans = 2;
//             break;
//         } else if (k3 == k33) {
//             ans = 3
//                 // console.log(k3 + " " + k33);
//             break;
//         } else {
//             ans = -1;
//         }
//     }
//     console.log(ans);

// }

"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 = Number(readline());
    var ans = 0;
    var k0 = 0;
    var k01 = 0;
    while (t--) {
        var arr = readline().split(' ').map(x => parseInt(x));
        var a = arr[0],
            b = arr[1];
        if (a > b) {
            var temp = b;
            b = a;
            a = temp;
        }
        for (var i = 0; i < 10000; i++) {
            // if (a < i) {
            //     k0 = i - a;
            // } else {
            //     k0 = a - i;
            // }
            // if (b < i) {
            //     k01 = i - b;
            // } else {
            //     k01 = b - i;
            // }
            var k1 = a + i;
            var k11 = b + i;
            var k2 = a + i;
            var k22 = i - b;
            var k3 = a - i;
            var k33 = b + i
            if (a == 0 && b == 0) {
                ans = 0;
                break;
            } else if (k1 == k11) {

                ans = 1;
                break;
            } else if (k2 == k22) {
                // console.log(k2 + " " + k22);
                ans = 2;
                break;
            } else if (k3 == k33) {
                ans = 3
                    // console.log(k3 + " " + k33);
                break;
            } else {
                ans = -1;
            }
        }
        console.log(ans);

    }

}

//Vismillahir Rahmanir Rahim (Allah hu Ackbar);

// var t = Number(readline());
// var ans = 0;
// var k0 = 0;
// var k01 = 0;
// while (t--) {
//     var arr = readline().split(' ').map(x => parseInt(x));
//     var a = arr[0],
//         b = arr[1];
//     if (a > b) {
//         var temp = b;
//         b = a;
//         a = temp;
//     }
//     for (var i = 0; i < 1000000; i++) {
//         if (a < i) {
//             k0 = i - a;
//         } else {
//             k0 = a - i;
//         }
//         if (b < i) {
//             k01 = i - b;
//         } else {
//             k01 = b - i;
//         }
//         var k1 = a + i;
//         var k11 = b + i;
//         var k2 = a + i;
//         var k22 = k01;
//         var k3 = k0;
//         var k33 = b + i
//         if (a == 0 && b == 0) {
//             ans = 0;
//             break;
//         } else if (k1 == k11) {

//             ans = 1;
//             break;
//         } else if (k2 == k22) {
//             // console.log(k2 + " " + k22);
//             ans = 2;
//             break;
//         } else if (k3 == k33) {
//             ans = 3
//                 // console.log(k3 + " " + k33);
//             break;
//         } else {
//             ans = -1;
//         }
//     }
//     console.log(ans);

// }

"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 = Number(readline());
    var ans = 0;
    var k0 = 0;
    var k01 = 0;
    while (t--) {
        var arr = readline().split(' ').map(x => parseInt(x));
        var a = arr[0],
            b = arr[1];
        if (a > b) {
            var temp = b;
            b = a;
            a = temp;
        }
        for (var i = 0; i < 10000; i++) {
            if (a < i) {
                k0 = i - a;
            } else {
                k0 = a - i;
            }
            if (b < i) {
                k01 = i - b;
            } else {
                k01 = b - i;
            }
            var k1 = a + i;
            var k11 = b + i;
            var k2 = a + i;
            var k22 = k01;
            var k3 = k0;
            var k33 = b + i
            if (a == 0 && b == 0) {
                ans = 0;
                break;
            } else if (k1 == k11) {

                ans = 1;
                break;
            } else if (k2 == k22) {
                // console.log(k2 + " " + k22);
                ans = 2;
                break;
            } else if (k3 == k33) {
                ans = 3
                    // console.log(k3 + " " + k33);
                break;
            } else {
                ans = -1;
            }
        }
        console.log(ans);

    }

}


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

let c = 0;

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

  const [a, b] = d.split(" ").map(Number);
  const ans = a + b * 2 + 1;

  if (a === 0) {
    console.log(1);
  } else {
    console.log(ans);
  }
  c++;
});

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

var t = parseInt(readline());

while(t--){
    var s = readline().split(' ');
	var a = parseInt(s[0]);
	var b = parseInt(s[1]);
	var res = b * 2 + a + 1;
	if(a == 0)res = 1;
	print(res);
}

var t = parseInt(readline());

while (t--) {
    // const [a, b] = readline().split(" ").map(function(x) { return parseInt(x); });
    // const [a, b] = readline().split(" ").map(x => parseInt(x));
    var ab = readline().split(' ');

    var a = parseInt(ab[0]);
    var b = parseInt(ab[1]);

    var r = a + 2 * b + 1;

    if (!a) {
        r = 1;
    }

    write(r);
    write('\n');
}

var test_cases = parseInt(readline());
var i;
for( i=0; i<test_cases; i++){
var coins = readline().split(" ");
var total_no=0;

if( parseInt(coins[0]) == 0 && parseInt(coins[1]) > 0){
	total_no =1;
	print(total_no);
}

else if (parseInt(coins[0]) == 0 && parseInt(coins[1]) == 0){
	total_no =1;
	print(total_no);
}

else if(parseInt(coins[0]) > 0 && parseInt(coins[1]) >= 0){
	total_no =  parseInt(coins[0]) + (parseInt(coins[1]) * 2)+1;
	print(total_no);
}
print("\n");
}

var t = readline();
for (var i=0 ; i < t ; i++){
    var inputs = readline().split(' ');
        a = inputs[0] , b = inputs[1];
        if(a == '0'){
            print(1);
        }
        else{
            print(parseInt(a) + (parseInt(b) * 2) + 1);
        }
}

var tests = parseInt(readline());
    for (var t=0; t < tests; t++) {
        var ab = readline().split(' ').map(x=>parseInt(x));
        var a = ab[0];
        var b = ab[1];
        if (a == 0) {
            print(1);
        } else {
            print(a + 2 * b + 1);
        }
    }

T = readline ()
while(T--){
   x = readline().split(' ').map(x => +x)
   a = x[0]
   b = x[1]

   if(a === 0)
      print(1)
   else
      print(a + b*2 +1)

}

var x = readline();

var res ="";
while(x--){

var arr = readline().split(' ');

res +=  arr[0] == 0 ?  1+'\n' : (+1 + +arr[0] + ( +arr[1] * 2 )) +'\n' ;
}
print(res);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function minSum(oneBurle,twoBurle){
    if(twoBurle===0){
        return oneBurle+1
    }
    else if(oneBurle===0){
        return 1
    }
    else{
        return (twoBurle*2) + oneBurle + 1
    }
}

function main() {

    const t = parseInt(readLine().trim(), 10);

    for (let tItr = 0; tItr < t; tItr++) {
        const vals = readLine().split(' ');

        const a = parseInt(vals[0], 10);
        const b = parseInt(vals[1], 10);
        const result = minSum(a,b);
        console.log(result)
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let t = readLine();
    t = parseInt(t);
    while(t--) {
        let line = readLine();
        line = line.split(" ");
        let n = parseInt(line[0]);
        let m = parseInt(line[1]);
       if(n!==0)
	   {console.log(n+2*m+1);}
		else console.log(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(); }); main(); }); function readLine() { return inputString[currentLine++]; }
function main() {
  const N = parseInt(readLine());

  for (let i = 0; i < N; i++) {
    const [ar, br] = readLine().split(' ');
    const a = Number(ar);
    const b = Number(br);

    if (a) {
      console.log(a + b * 2 + 1);
    } else {
      console.log(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 [a, b] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(a, b)
    }
    console.log(output.join('\n'))
// })()
})

function solve(a, b) {
    const odd = a >= 1 ? (Math.floor((a - 1) / 2) + b) * 2 + 1 : -1
    const even = (Math.floor(a / 2) + b) * 2
// console.log(odd, even)

    let ans
    if (odd === even + 1 || even === odd + 1) {
        ans = Math.max(odd, even) + 1
    } else {
        ans = Math.min(odd, even) + 1
    }
    return Math.max(1, ans)
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

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

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

    for (let test = 0; test < N; test++) {
        let [a, b] = readline().split(' ').map(Number);
        output(a === 0 ? 1 : b * 2 + a + 1);
    }
}

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var n = lines[0];
    for(j = 1; j <= n; j++){
        var a = lines[j].split(' ').map(Number);
        var one = a[0];
        var two = a[1] * 2;
        if(one === 0){
            console.log(1);
        }else{
            console.log(one + two + 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]
    for(j = 1; j <= n; j++){
        var a = lines[j].split(' ').map(Number)
        var one = a[0]
        var two = a[1] * 2
        if(one === 0){
            console.log(1)
        }else{
            console.log(one + two + 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();
    });

  main();
});

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

function main() {
  let t = parseInt(readLine());

  for (let i = 0; i < t; i++) {
    let [a, b] = readLine().split(" ").map(Number);

    if (a == 0) {
      console.log(1);
    } else if (b == 0) {
      console.log(a + 1);
    } else {
      a += b * 2;
      console.log(a + 1);
    }
  }
}

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

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    const [a, b] = readLine().split(" ").map(i => parseInt(i));
    if (a === 0 && b === 0) return 1;
    if (a === 0) return 1;
    return a + (2 * b) + 1;
}

const fs = require('fs')
const inputs = fs
  .readFileSync(0, 'utf-8')
  .split('\n')
  .map(line => line.trim().split(' ').map(Number))

const [n] = inputs[0]
const data = inputs.slice(1, n + 1)

main(n, data)
function main(n, data) {
  let res = []
  for (let [a, b] of data) {
    if (a === 0) res.push(1)
    else res.push(a + b * 2 + 1)
  }
  console.log(res.join('\n'))
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var A = nextInt();
		var B = nextInt();
		if(A >= 1){
			myout(A + (B * 2) + 1);
		}else{
			myout(1);
		}
	}
}

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

module.exports = E;

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

const EPS = 1e-6;

const calc = (a, b)=>{
  if (a==0)
    return 1;
  return a+b*2+1;
};

function main() {
    let T = +readline();
    while (T--){
      let [a, b] = ra();
      print(calc(a, b))
    }
}

E.calc = calc;

var t = parseInt(readline());

while(t--){
    var s = readline().split(' ');
	var a = parseInt(s[0]);
	var b = parseInt(s[1]);
	var res = b * 2 + a + 1;
	if(a <= b){
	    res = a * 3 + 1;
	}
	print(res + '\n');
}

var t = parseInt(readline());

while (t--) {
    // const [a, b] = readline().split(" ").map(function(x) { return parseInt(x); });
    // const [a, b] = readline().split(" ").map(x => parseInt(x));
    var ab = readline().split(' ');

    var a = parseInt(ab[0]);
    var b = parseInt(ab[1]);

    write(a + 2 * b + 1);
    write('\n');
}

let minSum = function(oneBurle,twoBurle){
    if(twoBurle==0){
        return oneBurle+1;
    }
    else if(oneBurle==0){
        return 1;
    }
    else{
        return (twoBurle*2) + oneBurle + 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();
    });

    main();
});

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

function main() {
    let t = readLine();
    t = parseInt(t);
    while(t--) {
        let line = readLine();
        line = line.split(" ");
        let n = parseInt(line[0]);
        let m = parseInt(line[1]);

		console.log(n+2*m+1);

    }
}

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

let c = 0;

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

  const [a, b] = d.split(" ").map(Number);
  const ans = a + b * 2 + 1;
  console.log(ans);
  c++;
});

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

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

function solve(a, b) {
    return binarySearch(1, 1e9, x => {
        const two = Math.min(Math.floor(x / 2), b)
        return two * 2 + a >= x
    }) + 1
}
function binarySearch(l, r, fn) {
    while (l <= r) {
        const m = Math.floor((l + r) / 2)
        if (fn(m)) {
            l = m + 1
        } else {
            r = m - 1
        }
    }
    return r
}


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 () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    /*const was = [];
    for(let i = 1; i <= 1000; i++) {
        was[i] = 1;
        for(let j = 2; j*j<=i; j++){
            if (i%j==0 && was[i-j] === 1) {
                was[i] = 0;
                break;
            }
            if (i%j ===0 && was[i-i/j] === 1) {
                was[i] = 0;
                break;
            }
        }
    }
    const was2=[];
    for(let i =2; i<=1000; i+=2)
        if (was[i]==1){
            was2.push(i);
        }
    console.log(was2.join(' '));*/
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        let n = parseInt(await getLine());
        let pow = 0;
        while (n%2==0){
            n=n/2;
            pow++;
        }
        if (pow == 0 || (pow%2==1 && n===1)) {
            console.log('Bob');
        }
        else
            console.log('Alice');
    }
}

solve();

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

const readLine = () => standardInputString[curLine++];

const readArray = (splitter, mapFunc) => readLine()
  .split(splitter)
  .map(mapFunc);

const eratosphenSieve = (limiter = 1e5) => {
  const sieve = new Array(limiter)
    .fill(true);
  sieve[0] = sieve[1] = false;

  for (let num = 2; num < sieve.length; num += 1) {
    if (num) {
      let mod = 2;

      while (num * mod < sieve.length) {
        sieve[num * mod] = false;
        mod += 1;
      }
    }
  }

  const simpleNums = [];
  sieve
    .forEach((item, ix) => {
      item && simpleNums.push(ix);
    });

  return simpleNums;
};

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

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

  main();
});

// https://codeforces.com/problemset/problem/1537/d

/**
 * Types of num n:
 * 1) odd
 *   - Has only odd dividers. After subtraction we obtain even number, since oddNum - oddNum = evenNum
 *   - Short: we can transit only to 3 state
 * 2) even which is power of 2
 *   - We can subtract half of number, since (n**2 % 2 === 0) and obtain another power of 2.
 *   - On the other hand we can subtract k*2, where k is a divider of n. In that case we obtain even number, which is not power of 2.
 *   - It is not power of 2, since n === k*2 * x (where x is power of 2) => n - k*2 === k*2 * x - k*2 => n - k*2 === (x - 1) * k*2. x is a power of 2 =>
 *   - => x - 1 is odd number.
 *   - Short: we can transit to 2 state of 3 state
 * 3) even
 *   - Since it is not power of 2 we have at least one odd divider => we can subtract it and get 1 state
 *   - We can subtract even number and change state to 3
 *
 * Our transitions between states:
 * 1 -> 3
 * 2 -> 2
 * 2 -> 3
 * 3 -> 1
 *
 * Profit of states:
 * 1) Our number is simple or it is 1 => Lose
 * 2) If we change state to 1 we lose => we should change state to 2 => if log(n) % 2 Win else Lose
 * 3) We can change state to 1 => Win
 */

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

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

    const binaryN = n.toString(2);
    const powerOfTwo = binaryN.length - 1;

    if (n % 2 === 1) {
      console.log("Bob");
    } else if (binaryN === Math.pow(2, powerOfTwo).toString(2)) {
      console.log(powerOfTwo % 2 === 0 ? "Alice" : "Bob");
    } else {
      console.log("Alice");
    }
  }
};

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

const readLine = () => standardInputString[curLine++];

const readArray = (splitter, mapFunc) => readLine()
  .split(splitter)
  .map(mapFunc);

const eratosphenSieve = (limiter = 1e5) => {
  const sieve = new Array(limiter)
    .fill(true);
  sieve[0] = sieve[1] = false;

  for (let num = 2; num < sieve.length; num += 1) {
    if (num) {
      let mod = 2;

      while (num * mod < sieve.length) {
        sieve[num * mod] = false;
        mod += 1;
      }
    }
  }

  const simpleNums = [];
  sieve
    .forEach((item, ix) => {
      item && simpleNums.push(ix);
    });

  return simpleNums;
};

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

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

  main();
});

// https://codeforces.com/problemset/problem/1537/d

/**
 * Types of num n:
 * 1) odd
 *   - Has only odd dividers. After subtraction we obtain even number, since oddNum - oddNum = evenNum
 *   - Short: we can transit only to 3 state
 * 2) even which is power of 2
 *   - We can subtract half of number, since (n**2 % 2 === 0) and obtain another power of 2.
 *   - On the other hand we can subtract k*2, where k is a divider of n. In that case we obtain even number, which is not power of 2.
 *   - It is not power of 2, since n === k*2 * x (where x is power of 2) => n - k*2 === k*2 * x - k*2 => n - k*2 === (x - 1) * k*2. x is a power of 2 =>
 *   - => x - 1 is odd number.
 *   - Short: we can transit to 2 state of 3 state
 * 3) even
 *   - Since it is not power of 2 we have at least one odd divider => we can subtract it and get 1 state
 *   - We can subtract even number and change state to 3
 *
 * Our transitions between states:
 * 1 -> 3
 * 2 -> 2
 * 2 -> 3
 * 3 -> 1
 *
 * Profit of states:
 * 1) Our number is simple or it is 1 => Lose
 * 2) If we change state to 1 we lose => we should change state to 2 => if log(n) % 2 Win else Lose
 * 3) We can change state to 1 => Win
 */

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

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

    const binaryN = n.toString(2);
    const powerOfTwo = binaryN.length - 1;
    console.log(powerOfTwo, binaryN, Math.pow(2, powerOfTwo).toString(2));

    if (n % 2 === 1) {
      console.log("Bob");
    } else if (binaryN === Math.pow(2, powerOfTwo).toString(2)) {
      console.log(powerOfTwo % 2 === 0 ? "Alice" : "Bob");
    } else {
      console.log("Alice");
    }
  }
};

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 () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        let n = parseInt(await getLine());
        let pow = 0;
        while (n%2==0){
            n/=2;
            pow++;
        }
        if (pow = 0 || (pow%2==1 && n===1)) {
            console.log('Bob');
        }
        else
            console.log('Alice');
    }
}

solve();


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline());
	var pairNum = n*(n-1)/2;

	var counts = [];
	for (var i = 0; i <= n; ++i) {
		counts.push({ win: 0, lose: 0 });
	}

	for (var i = 1; i < pairNum; ++i) {
		var pair = tokenizeIntegers(readline());
		counts[pair[0]].win += 1;
		counts[pair[1]].lose += 1;
	}

	var missing = [];
	for (var i = 1; i <= n; ++i) {
		if (counts[i].win + counts[i].lose != n-1) {
			missing.push(i);
		}
	}

	if (counts[missing[0]].win > counts[missing[1]].win) {
		print(missing[0]+" "+missing[1]);
	}
	else {
		print(missing[1]+" "+missing[0]);
	}
}

main();

'use strict'

const N = +readline()
let lll

let ps = []

while (lll = readline()) {
  lll = lll.split(' ').map(v => parseInt(v))
  const v = lll[0]
  const l = lll[1]
  if (!ps[v]) {ps[v] = {bt: [], wt: [], n: 0, i: v}}
  ps[v].bt.push(l)
  ps[v].n++
  if (!ps[l]) {ps[l] = {bt: [], wt: [], n: 0, i: l}}
  ps[l].wt.push(v)
  ps[l].n++
}

let min = Infinity

for (let i = 1; i < ps.length; i++) {
  min = Math.min(ps[i].n, min)
}

let ms = []

for (let i = 1; i < ps.length; i++) {
  if (ps[i].n == min) ms.push(ps[i])
}

let fv
for (let i = 1; i < ms[0].bt.length; i++) {
  if (~ms[1].wt.indexOf(ms[0].bt[i])) {
    fv = true;
    break
  }
}

print(fv ? ms[0].i + ' ' + ms[1].i : ms[1].i + ' ' + ms[0].i)

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline());
	var pairNum = n*(n-1)/2;

	var counts = [];
	for (var i = 0; i <= n; ++i) {
		counts.push({ win: 0, lose: 0 });
	}

	for (var i = 1; i < pairNum; ++i) {
		var pair = tokenizeIntegers(readline());
		counts[pair[0]].win += 1;
		counts[pair[1]].lose += 1;
	}

	var missing = [];
	for (var i = 1; i <= n; ++i) {
		if (counts[i].win + counts[i].lose != n-1) {
			missing.push(i);
		}
	}

	if (missing[0].win > missing[1].win) {
		print(missing[0]+" "+missing[1]);
	}
	else {
		print(missing[1]+" "+missing[0]);
	}
}

main();

'use strict'

const N = +readline()
let lll

let ps = []

while (lll = readline()) {
  lll = lll.split(' ').map(v => parseInt(v))
  const v = lll[0]
  const l = lll[1]
  if (!ps[v]) {ps[v] = {bt: [], wt: [], n: 0, i: v}}
  ps[v].bt.push(l)
  ps[v].n++
  if (!ps[l]) {ps[l] = {bt: [], wt: [], n: 0, i: l}}
  ps[l].wt.push(v)
  ps[l].n++
}

let min = Infinity

for (let i = 1; i < 4; i++) {
  min = Math.min(ps[i].n, min)
}

let ms = []

for (let i = 1; i < ps.length; i++) {
  if (ps[i].n == min) ms.push(ps[i])
}

let fv
for (let i = 1; i < ms[0].bt.length; i++) {
  if (~ms[1].wt.indexOf(ms[0].bt[i])) {
    fv = true;
    break
  }
}

print(fv ? ms[0].i + ' ' + ms[1].i : ms[1].i + ' ' + ms[0].i)


readline()
k=1
for(i of readline().split(' ').sort((a,b)=>a-b))k+=i>=k
print(k)

var n = Number(readline());
var array = readline().split(' ').map(Number);

array.sort(function(a, b) {return a - b});

// k is the new value for array[i];
var k = 1;

for (var i = 0; i < n; i++) {
	if (array[i] >= k) {
		array[i] = k;
		k ++;
	}
}

var mex = array[n - 1] + 1;

print(mex);

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var ans = 1, arr, n;

n = Number(readline());
arr = readline().split(' ').map(Number).sort((a, b) => a - b);

for (i = 0; i < n; i++) {

    if (arr[i] >= ans) {

        ans++;
    }
}

print(ans);

l=+readline(),a=readline().split(' ').sort((a,b)=>a-b),k=1;
for(var i of a)if(+i>=k)++k;
print(k);

var n = parseInt(readline());
var input = readline().split(' ').map(function(item){return parseInt(item)}).sort(function(a, b){return a-b})
var gaps = input[0] - 1, repeat = 0;
for(var i = 1; i < input.length; i++){
	var diff = input[i] - input[i-1];
	if(diff === 0){
		if(gaps === 0){
			repeat++;
		} else {
			gaps--;
		}
	} else {
		gaps += diff - 1;
	}
}
var mex = n - repeat + 1;
print(mex);

		var arr = [],
			mex=1,
			quantity = readline().split(" ").map(function(x) { return parseInt(x); }),
			string = readline().split(" ").map(function(x) { return parseInt(x); });
		for (var i = 0; i < quantity; i++)
		{
			arr[i] = parseInt(string[i],10);
		}
		function compareNumeric(a, b)
		{
  			if (a > b) return 1;
  			if (a < b) return -1;
		}
		arr.sort(compareNumeric);
		for (var i = 0; i < arr.length; i++) {
			if (arr[i] >= mex)
				mex++;
		}
		print(mex);

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var ans = 1, arr, n;

n = Number(readline());
arr = readline().split(' ').map(Number).sort();

for (i = 0; i < n; i++) {

    if (arr[i] >= ans) {

        ans++;
    }
}

print(ans);

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var ans = 1, arr, n;

n = Number(readline());
arr = readline().split(' ').map(Number).sort();

for (i = 0; i < arr.length; i++) {

    if (arr[i] >= ans) {

        ans++;
    }
}

print(ans);

var n=+readline(),ar=readline().split(' '),i=0,k=1,l=ar.length;
for(i=l;i--;)ar[i]=+ar[i];
ar.sort();
for(i=0;i<l;++i)if(ar[i]>=k)++k;
print(k);

		var arr = [],
			mex=0,
			quantity = readline().split(" ").map(function(x) { return parseInt(x); }),
			string = readline().split(" ").map(function(x) { return parseInt(x); });
		for (var i = 0; i < quantity; i++)
		{
			arr[i] = parseInt(string[i],10);
		}
		function compareNumeric(a, b)
		{
  			if (a > b) return 1;
  			if (a < b) return -1;
		}
		arr.sort(compareNumeric);
		for (var i = 0; i < arr.length; i++) {
			if (arr[i] >= mex)
				mex++;
		}
		print(mex);

		var arr = [],
			mex=0,
			quantity = readline().split(" ").map(function(x) { return parseInt(x); }),
			string = readline().split(" ").map(function(x) { return parseInt(x); });
		for (var i = 0; i < quantity; i++)
		{
			arr[i] = parseInt(string[i],10);
		}
		function compareNumeric(a, b)
		{
  			if (a > b) return 1;
  			if (a < b) return -1;
		}
		arr.sort(compareNumeric);
		for (var i = 0; i <= arr.length; i++)
		{
			arr[0] = 1;
			while (arr[i] + 1 < arr[i+1])
			{
				if ((arr[i] + 1) < arr[i+1])
				{
					arr[i+1] = arr[i+1] - 1;
				}

			}
		}
		var max = 0;
		for (var i = 1; i < arr.length; i++) {
			if (arr[i] > arr[i-1])
			{
				max = arr[i];
			}
		}
		mex = max + 1;
		print(mex);

		var arr = [],
			mex=0,
			quantity = readline().split(" ").map(function(x) { return parseInt(x); }),
			string = readline().split(" ").map(function(x) { return parseInt(x); });
		for (var i = 0; i < quantity; i++)
		{
			arr[i] = parseInt(string[i],10);
		}
		function compareNumeric(a, b)
		{
  			if (a > b) return 1;
  			if (a < b) return -1;
		}
		arr.sort(compareNumeric);
		for (var i = 0; i <= arr.length; i++)
		{
			arr[0] = 1;
			while (arr[i] + 1 < arr[i+1])
			{
				if ((arr[i] + 1) < arr[i+1])
				{
					arr[i+1] = arr[i+1] - 1;
				}

			}
		}
		var max = 0;
		for (var i = 1; i < arr.length; i++) {
			if (arr[i] > arr[i-1])
			{
				max = arr[i];
			}
		}
		if (max == 1) {
		    mex = 1;
		}
		else mex = max + 1;
		print(mex);

		var arr = [],
			mex=0,
			quantity = readline().split(" ").map(function(x) { return parseInt(x); }),
			string = readline().split(" ").map(function(x) { return parseInt(x); });
		for (var i = 0; i < quantity; i++)
		{
			arr[i] = parseInt(string[i],10);
		}

		for (var i = 0; i <= arr.length; i++)
		{
			arr[0] = 1;
			while (arr[i] + 1 < arr[i+1])
			{
				if ((arr[i] + 1) < arr[i+1])
				{
					arr[i+1] = arr[i+1] - 1;
				}

			}
		}
		var max = 1;
		for (var i = 1; i < arr.length; i++) {
			if (arr[i] > arr[i-1])
			{
				max = arr[i];
			}
		}
		mex = max + 1;
		print(mex);