Polycarp remembered the $$$2020$$$-th year, and he is happy with the arrival of the new $$$2021$$$-th year. To remember such a wonderful moment, Polycarp wants to represent the number $$$n$$$ as the sum of a certain number of $$$2020$$$ and a certain number of $$$2021$$$.For example, if:   $$$n=4041$$$, then the number $$$n$$$ can be represented as the sum $$$2020 + 2021$$$;  $$$n=4042$$$, then the number $$$n$$$ can be represented as the sum $$$2021 + 2021$$$;  $$$n=8081$$$, then the number $$$n$$$ can be represented as the sum $$$2020 + 2020 + 2020 + 2021$$$;  $$$n=8079$$$, then the number $$$n$$$ cannot be represented as the sum of the numbers $$$2020$$$ and $$$2021$$$. Help Polycarp to find out whether the number $$$n$$$ can be represented as the sum of a certain number of numbers $$$2020$$$ and a certain number of numbers $$$2021$$$.

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case contains one integer $$$n$$$ ($$$1 \leq n \leq 10^6$$$) — the number that Polycarp wants to represent as the sum of the numbers $$$2020$$$ and $$$2021$$$.

For each test case, output on a separate line:    "YES" if the number $$$n$$$ is representable as the sum of a certain number of $$$2020$$$ and a certain number of $$$2021$$$;  "NO" otherwise.  You can output "YES" and "NO" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).

z = +readline();
while (z--) {
  x = +readline();
  y = x / 2020;
  w = Math.floor(y);
  q = x % 2020;
  if (q <= w) {
    print("YES");
  } else {
    print("NO");
  }
}

const cases = readline()
var temp
var flag = 0
for (var i = 0; i < cases; i++) {
    inp = readline()
    temp = parseInt(inp, 10)
    if (temp % 2020 == 0) {
        flag++
        print("Yes")
    } else if (temp % 2021 == 0) {
        flag++
        print("Yes")
    } else {
        while (temp >= 2020) {
            temp = temp - 2020
            if (temp % 2021 == 0) {
                flag++
                print("Yes")
            }
        }
    }
    if (flag < 1) {
        print("No")
    }
    flag = 0
}

var num = parseInt(readline());
var arr = new Map();
const process = (n) => {
  if (arr.has(n))
    return arr.get(n);
  if (n < 2020)
    return 0;
  if (n % 2020 == 0 || n % 2021 == 0)
    return 1;
  var temp = process(n-2020) ? 1 : process(n-2021);
  arr.set(n, temp);
  return temp;
}
for (var i = 0; i < num; i++) {
  var input = parseInt(readline());
  result = process(input) ? "YES" : "NO";
  print(result);
}

var n = +readline();
for(var i = 0; i < n; i++) {
  var temp = +readline();
  print((temp % 2020) > (temp / 2020) ? 'NO' : 'YES');
}

var a = parseInt(readline());

  while (a--) {
    var n = parseInt(readline());

    var mod = n % 2020;
    var div = n / 2020;

    if (mod <= div) {
      print("YES");
    } else {
      print("NO");
    }
  }

var print = this.print || require('lol-io').print
var write = this.write || require('lol-io').write
var readline = this.readline || require('lol-io').readline

var t=parseInt(readline());
while(t--){
    var n=parseInt(readline());
      print(solve(n));

}

function solve(n){
    for(var i=0;i<1000;i++){
        var b=n-(2020*i);
        if(b<0)break;
        if(b%2021==0){
          return  "YES";
        }
    }
   return "NO";
}

var cnt = +readline();
var arr = [];
for(var i = 0; i < cnt; i++) {
    arr.push(readline());
}

function newYearsNumber(n) {
  if (n < 2020) {
    return 'NO';
  }

  if (n % 2020 === 0 || n % 2021 === 0) {
    return 'YES';
  }

  return newYearsNumber(n - 2021);
}

for (var i = 0; i < arr.length; i++) {
  print(newYearsNumber(arr[i]))
}

"use strict"

let iter = parseInt(readline());

while(iter--){
    let input = parseInt(readline());
    let a = Math.trunc(input / 2020);
    let b = input % 2020;
    if(b <= a){
        print("YES");
    } else {
        print("NO");
    }
}

let i = '';//.map(Number).sort(function(a, b){return a - b})
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 k = lines[j]
	    var a = Math.floor(k / 2020)
	 	var b = k % 2020
	    console.log(a >= b ? 'YES' : 'NO')
	}
});//k[k.length - 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 k = lines[j]
	    var a = k % 2020
	    var b = Math.floor(k / 2020)
	    console.log(a <= b ? 'YES' : 'NO')
	}
});

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(1)(chunk[i])
          }
          else {
            strings.push(chunk[i])
          }
        }
      }
    }
  })
  const fn = resolve => {
    if (strings.length > 0) {
      resolve(strings.shift(1))
    }
    else {
      listeners.push(resolve)
    }
  }
  return () => new Promise(fn)
})()

async function main() {
  let t = +await nextString()
  for (let i = 0; i < t; ++i) {
    let n = +await nextString()
    if (Number.isNaN(n)) while (true);
    let k = Math.floor(n / 2020)
    let p = n % (2020 * k)
    if (p <= k) {
      console.log('YES')
    }
    else {
      console.log('NO')
    }
  }
  process.exit(0)
}

main()

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

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

function main() {
	const map = new Map();
	for (let i = 0; i <= 1000; i++) {
		for (let j = 0; j <= 1000; j++) {
			const ans = 2020 * i + 2021 * j;
			map.set(ans, true);
		}
	}
	let t = +readLine();
	while (t--) {
		const n = +readLine();
		if (map.has(n)) console.log('YES');
		else console.log('NO');
	}
}

let readline = require("readline");

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

let input = [];
rl.on("line", function (line) {
  input.push(line.split(" "));

  if (input.length === +input[0] + 1) {
    // call your function here
    solve(input);
    rl.close();
  }
});

let solve = (input) => {
  for (let i = 1; i < input.length; i++) {
    let n = +input[i];

    let count21 = n % 2020;

    let count20 = (n - 2021 * count21) / 2020;

    if (count20 >= 0 && 2020 * count20 + 2021 * count21 === n)
      console.log("YES");
    else console.log("NO");
  }
};

let readline = require("readline");

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

let input = [];
rl.on("line", function (line) {
  input.push(line.split(" "));

  if (input.length === +input[0] + 1) {
    // call your function here
    solve(input);
    rl.close();
  }
});

let solve = (input) => {
  for (let i = 1; i < input.length; i++) {
    let n = +input[i];

    while (n > 0) {
      if (n % 2020 !== 0) {
        n -= 2021;
      } else {
        break;
      }
    }

    if (n % 2020 === 0 && n >= 0) console.log("YES");
    else console.log("NO");
  }
};

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var L = Math.floor(N / 2020);
    var R = N % 2020;
    if(L < R){
      myout("NO");
    }else{
      myout("YES");
    }
  }
}

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
	var t = lines[0];
	for(i = 1; i <= t; i++){
	    var n = lines[i];
	    var a = n % 2020;
	    var b = Math.floor(n / 2020);
	    console.log(a <= b ? 'YES' : 'NO');
	}
});

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

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

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let year = +input[z++];
        if((year % 2020 === 0) || (year % 2021 === 0)){
            console.log("YES");
        }
        else{
            let onesMultipal = year % 2020;
            let zerosMultipal = Math.abs((year % 2021) - 2021);
            if((2020 * zerosMultipal) + (2021 * onesMultipal) == year){
                console.log("YES");
            }
            else{
                console.log("NO");
            }
        }
    }
}

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

let input = [];
rl.on("line", function(line) {
    input.push(line);
}).on("close", function() {
    solution(input);
    process.exit();
});

function solution(input) {
    const num = input.slice(1).map(v => Number(v));

    for(let val of num) {
        let cnt21 = val % 2020;
        let cnt20 = (val - cnt21) / 2020 - cnt21;

        if(cnt20 >= 0 && 2020 * cnt20 + 2021 * cnt21 === val) {
            console.log("YES");
        } else console.log("NO");
    }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main()
});

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

function main() {
  let testCases = readline()
  while(testCases--)
    solve()
}

// function to solve problems
function solve (){
  let num = parseInt(readline())
  // ====== SOLUTION ======
  // if (num % 2021 == 0){
  //     console.log('YES')
  //     return
  // }
  while(num > 2019){
    // console.log('num = ', num)
    if (num % 2020 == 0 || num % 2021 == 0){
      console.log('YES')
      return
    }
    num -= 2021
  }
  console.log('NO')
}

const cases = readline()
var temp
var flag = 0
for (var i = 0; i < cases; i++) {
    inp = readline()
    temp = parseInt(inp, 10)
    if (temp % 2020 == 0) {
        flag++
        print("Yes")
    } else if (temp % 2021 == 0) {
        flag++
        print("Yes")
    } else {
        while (temp >= 2020) {
            temp = temp - 2020
            if (temp % 2021 == 0) {
                flag++
                print("Yes")
            }
        }
    }
    if (flag < 1) {
        print("No")
        flag = 0
    }
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var a = lines[j].split('')
        if(a.length >= 4){
        console.log(a[0] == a[2] || lines[j] % 2021 === 0 || lines[j] % 2020 === 0? 'YES' : 'NO')
    }else{
        console.log('NO')
    }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var a = lines[j].split('')
        if(a.length >= 4){
        console.log(a[0] == a[2] || lines[j] % 2021 === 0 || lines[j] % 2020 === 0? 'YES' : 'NO')}
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var a = lines[j].split('')
        console.log(a[0] == a[2] || lines[j] % 2021 === 0 || lines[j] % 2020 === 0? 'YES' : 'NO')
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var a = lines[j].split('')
        console.log(a[0] == a[2] ? 'YES' : 'NO')
    }
});

const nextString = (function() {
  const l = [], s = [], p = process.stdin
  p.setEncoding('utf8')
  p.on('readable', () => {
    for (let c; (c = p.read()) !== null;) {
      c = c.split(/\r\n|\r|\n| /)
      for (let i = 0; i < c.length; ++i) {
        if (c[i].length > 0) {
          if (l.length > 0) {
            l.shift(1)(c[i])
          }
          else {
            s.push(c[i])
          }
        }
      }
    }
  })
  const f = r => {
    if (s.length > 0) {
      r(s.shift(1))
    }
    else {
      l.push(r)
    }
  }
  return () => new Promise(f)
})()

async function main() {
  let t = +await nextString()
  for (let i = 0; i < t; ++i) {
    let n = +await nextString()
    if (Number.isNaN(n)) while (true);
    let k = Math.floor(n / 2020)
    let p = n % (2020 * k)
    if (p <= k) {
      console.log('YES')
    }
    else {
      console.log('NO')
    }
  }
}

main()

setTimeout(() => process.exit(0), 800)

const nextString = (function() {
  const l = [], s = [], p = process.stdin
  p.setEncoding('utf8')
  p.on('readable', () => {
    for (let c; (c = p.read()) !== null;) {
      c = c.split(/\r\n|\r|\n/)
      for (let i = 0; i < c.length; ++i) {
        if (c[i].length > 0) {
          if (l.length > 0) {
            l.shift(1)(c[i])
          }
          else {
            s.push(c[i])
          }
        }
      }
    }
  })
  const f = r => {
    if (s.length > 0) {
      r(s.shift(1))
    }
    else {
      l.push(r)
    }
  }
  return () => new Promise(f)
})()

async function main() {
  let t = +await nextString()
  for (let i = 0; i < t; ++i) {
    let n = +await nextString()
    if (Number.isNaN(n)) while (true);
    let k = Math.floor(n / 2020)
    let p = n % (2020 * k)
    if (p <= k) {
      console.log('YES')
    }
    else {
      console.log('NO')
    }
  }
}

main()

setTimeout(() => process.exit(0), 800)

const nextString = (function() {
  const l = [], s = [], p = process.stdin
  p.setEncoding('utf8')
  p.on('readable', () => {
    for (let c; (c = p.read()) !== null;) {
      c = c.split(/\r\n|\r|\n/)
      for (let i = 0; i < c.length; ++i) {
        if (c[i].length > 0) {
          if (l.length > 0) {
            l.shift(1)(c[i])
          }
          else {
            s.push(c[i])
          }
        }
      }
    }
  })
  const f = r => {
    if (s.length > 0) {
      r(s.shift(1))
    }
    else {
      l.push(r)
    }
  }
  return () => new Promise(f)
})()

async function main() {
  let t = +await nextString()
  for (let i = 0; i < t; ++i) {
    let n = +await nextString()
    let k = Math.floor(n / 2020)
    let p = n % (2020 * k)
    if (p <= k) {
      console.log('YES')
    }
    else {
      console.log('NO')
    }
  }
}

main()

setTimeout(() => process.exit(0), 800)

const nextString = (function() {
  const l = [], s = [], p = process.stdin
  p.setEncoding('utf8')
  p.on('readable', () => {
    for (let c; (c = p.read()) !== null;) {
      c = c.split(/\r\n|\r|\n/)
      for (let i = 0; i < c.length; ++i) {
        if (c[i].length > 0) {
          if (l.length > 0) {
            l.shift(1)(c[i])
          }
          else {
            s.push(c[i])
          }
        }
      }
    }
  })
  const f = r => {
    if (s.length > 0) {
      r(s.shift(1))
    }
    else {
      l.push(r)
    }
  }
  return () => new Promise(f)
})()

async function main() {
  let t = +await nextString()
  for (let i = 0; i < t; ++i) {
    let n = +await nextString()
    let k = Math.floor(n / 2020)
    let p = n % (2020 * k)
    if (p <= k) {
      console.log('YES')
    }
    else {
      console.log('NO')
    }
  }
  process.exit(0)
}

main()

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

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

function main() {
	let t = +readLine();
	while (t--) {
		let n = +readLine();
		if (n < 2020 || n < 2021) console.log('NO');
		else {
			let found = false;
			if (n % 2020 === 0 || n % 2021 === 0) {
				console.log('YES');
				found = true;
			} else {
				const [div, rem] = [Math.floor(n / 2020), n % 2020];
				if (rem <= div) {
					found = true;
					console.log('YES');
				}
				!found && console.log('NO');
			}
		}
	}
}

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

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

function main() {
	let t = +readLine();
	while (t--) {
		let n = +readLine();
		if (n < 2020 || n < 2021) console.log('NO');
		else {
			let found = false;
			if (n % 2020 === 0 || n % 2021 === 0) {
				console.log('YES');
				found = true;
			} else {
				const rem = n % 4041;
				if (rem === 0 || rem % 2020 === 0 || rem % 2021 === 0) {
					console.log('YES');
					found = true;
				}
				!found && console.log('NO');
			}
		}
	}
}


As their story unravels, a timeless tale is told once again...Shirahime, a friend of Mocha's, is keen on playing the music game Arcaea and sharing Mocha interesting puzzles to solve. This day, Shirahime comes up with a new simple puzzle and wants Mocha to solve them. However, these puzzles are too easy for Mocha to solve, so she wants you to solve them and tell her the answers. The puzzles are described as follow.There are $$$n$$$ squares arranged in a row, and each of them can be painted either red or blue.Among these squares, some of them have been painted already, and the others are blank. You can decide which color to paint on each blank square.Some pairs of adjacent squares may have the same color, which is imperfect. We define the imperfectness as the number of pairs of adjacent squares that share the same color.For example, the imperfectness of "BRRRBBR" is $$$3$$$, with "BB" occurred once and "RR" occurred twice.Your goal is to minimize the imperfectness and print out the colors of the squares after painting.

Each test contains multiple test cases.  The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of two lines. The first line of each test case contains an integer $$$n$$$ ($$$1\leq n\leq 100$$$) — the length of the squares row. The second line of each test case contains a string $$$s$$$ with length $$$n$$$, containing characters 'B', 'R' and '?'. Here 'B' stands for a blue square, 'R' for a red square, and '?' for a blank square.

For each test case, print a line with a string only containing 'B' and 'R', the colors of the squares after painting, which imperfectness is minimized. If there are multiple solutions, print any of them.

NoteIn the first test case, if the squares are painted "BRRBRBR", the imperfectness is $$$1$$$ (since squares $$$2$$$ and $$$3$$$ have the same color), which is the minimum possible imperfectness.

var readNumber = () => +readline();
var readStr = () => readline();
var n = readNumber();

for (var i = 0; i < n; i++) {
    readNumber();
    var array = readStr().split('');
    paint(array);
}

function paint(input) {
    var firstPaintedIndex = -1;
    adjacentColor = "R";
    for (var index = 0; index < input.length; index++) {
        if (input[index] != '?') {
            firstPaintedIndex = index;
            adjacentColor = input[index];
            break;
        }
    }

    if (firstPaintedIndex != -1) {
        //paint left
        for (var index = firstPaintedIndex - 1; index >= 0; index--) {
            input[index] = adjacentColor == 'B' ? 'R' : 'B';
            adjacentColor = input[index];
        }

        adjacentColor = input[firstPaintedIndex]
    }
    //paint right
    for (var index = firstPaintedIndex + 1; index < input.length; index++) {
        var current = input[index];
        if (current == '?') {
            input[index] = adjacentColor == 'B' ? 'R' : 'B';
        }
        adjacentColor = input[index];
    }

    print(input.join(''));
}

'use strict'
Object.defineProperty(exports, '__esModule', { value: !0 })
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  lineIndex = 0
  lines = []
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const e = this.lines[this.lineIndex]
    return (this.lineIndex += 1), e
  }
  readLineAsNumber() {
    return Number(this.readLine())
  }
  readIntegersOfLine() {
    const e = this.readLine().match(integerRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  readNumsOfLine() {
    const e = this.readLine().match(decimalRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  print(e) {
    stdout.write(e)
  }
  async init() {
    const e = await this.readLines()
    this.lines = e
  }
  readLines() {
    const e = []
    return new Promise(n => {
      stdin.on('data', n => e.push(n)),
        stdin.on('end', function () {
          const t = e.join('').split(os.EOL)
          n(t)
        })
    })
  }
}
async function __main__(e) {
  const n = new InputAndOutput()
  await n.init(), e(n)
}
const regex = /([?]+)/g
function solve(e, n) {
  return n.replace(regex, (t, s, i) => {
    let r = 'B'
    if ((i > 0 && (r = 'R' === n[i - 1] ? 'B' : 'R'), i + s.length < e)) {
      const e = n[i + s.length]
      r = 'R' === e ? (1 & s.length ? 'B' : 'R') : 1 & s.length ? 'R' : 'B'
    }
    const o = 'R' === r ? 'B' : 'R'
    return s
      .split('')
      .map((e, n) => (1 & n ? o : r))
      .join('')
  })
}
__main__(function (e) {
  const n = e.readLineAsNumber()
  for (let t = 1; t <= n; ++t) {
    const n = solve(e.readLineAsNumber(), e.readLine().trim())
    e.print(n + '\n')
  }
})

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

const readLine = () => dataitr.next().value.trim();
function rl () {
	let ans = readLine().split(' ');
	if (!isNaN(Number(ans[0]))) ans = ans.map(x => Number(x));
	return ans.length == 1 ? ans[0] : ans;
}

const rev = c => c == 'B' ? 'R' : 'B';

function main () {
	let t = rl();
	while (t--) {
		let n = rl();
		let s = rl().split('');

		if (s[0] == '?') {
			let i = 0;
			while (i < n && s[i] == '?') i++;
			if (i == n) s[0] = 'B';
			else if (i % 2 == 1) s[0] = rev(s[i]);
			else s[0] = s[i];
		}

		for (let i = 1; i < n; i++) {
			if (s[i] == '?') {
				s[i] = rev(s[i - 1]);
			}
		}

		console.log(s.join(''));
	}
}

const input = [];

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

rl.on('line', line => input.push(line));

rl.on('close', doWork);

let line = 0;

function lineToStrArray(split = ' ') {
  const val = input[line].split(split);
  line += 1;
  return val;
}

function lineToNumArray(split = ' ') {
  const val = input[line].split(split).map(e => +e);
  line += 1;
  return val;
}

function doWork() {
  const [t] = lineToNumArray();

  for (let t1 = 0; t1 < t; t1 += 1) {
    const [n] = lineToNumArray();
    const [str] = lineToStrArray();

    const splitStr = str.split('');

    if (splitStr.every(e => e === '?')) {
      splitStr[0] = 'R';
    }

    while (splitStr.includes('?')) {
      let next = null;
      for (let i = 0; i < splitStr.length; i += 1) {
        if (splitStr[i] !== '?') {
          next = splitStr[i] === 'B' ? 'R' : 'B';
        } else if (next !== null) {
          splitStr[i] = next;
          next = splitStr[i] === 'B' ? 'R' : 'B';
        }
      }
      next = null;
      for (let i = splitStr.length - 1; i >= 0; i -= 1) {
        if (splitStr[i] !== '?') {
          next = splitStr[i] === 'B' ? 'R' : 'B';
        } else if (next !== null) {
          splitStr[i] = next;
          next = splitStr[i] === 'B' ? 'R' : 'B';
        }
      }
    }
    console.log(splitStr.join(''));
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
	let numberOfLines = parseInt(readline(), 10) * 2
	for(let i = 0; i < numberOfLines; i++) {
		let x = readline().trim()
		if(i % 2 === 1) {
			console.log(solve(x))
		}
		// print(solve(x))
		// fs.appendFileSync("output.txt", `Case #${i+1}: ${solve(x)}` + "\n")
	}

}

function solve(str) {
    let arr = str.split("");
	let numOfUnknown = 0
	let queue = []
	for(let i = 0; i < arr.length; i++) {
		if(arr[i] !== "?") queue.push(i)
		else numOfUnknown++
	}
	if(numOfUnknown > 0 && !queue.length) {
		arr[0] = "B"
		queue.push(0)
	}
	while(queue.length && numOfUnknown) {
		let current = queue.pop()
		if(current > 0 && arr[current - 1] === "?") {
			if(arr[current] === "B") arr[current-1] = "R"
			else arr[current-1] = "B"
			queue.push(current - 1)
			numOfUnknown--
		}
		if(current < arr.length - 1 && arr[current + 1] === "?") {
			if(arr[current] === "B") arr[current + 1] = "R"
			else arr[current + 1] = "B"
			queue.push(current + 1)
			numOfUnknown--
		}
	}

	return arr.join("")
}

let inputBuffer = ''
process.stdin.on('data', data => {
	inputBuffer += data
})
process.stdin.on('end', _ => {
	inputBuffer = inputBuffer.trim().split('\n')

	main()
})

let currentLine = 0
function readline() {
	return inputBuffer[currentLine++]
}
function readint() {
	return parseInt(readline(), 10)
}
function readints() {
	return readline().split(' ').map(s => parseInt(s, 10))
}
function print(s) {
	process.stdout.write(s + '\n')
}
function write(s) {
	process.stdout.write(s)
}

function range(lowerBound, upperBound = undefined, step = 1) {
	if (upperBound === undefined) {
		upperBound = lowerBound
		lowerBound = 0
	}
	let ret = []
	if (lowerBound <= upperBound) {
		for (let i = lowerBound; i < upperBound; i += step) ret.push(i)
	} else {
		for (let i = lowerBound; i > upperBound; i -= step) ret.push(i)
	}
	return ret
}
function loop(lowerBound, upperBound = undefined, step = 1) {
	return (func) => {
		range(lowerBound, upperBound, step).forEach(i => func(i))
	}
}

function main() {
	let t = readint()
	loop(t)(_ => {
		let n = readint()
		let s = readline()
		let indB = s.indexOf('B')
		let indR = s.indexOf('R')
		let ans = ''
		if (indB === -1 && indR === -1) {
			loop(n)(i => ans += 'BR'[i%2])
		} else {
			let ind = Math.max(indB, indR);
			s = s.split('')
			loop(ind + 1, n)(i => {
				if (s[i] === '?') s[i] = s[i-1] === 'R' ? 'B' : 'R'
			})
			loop(ind - 1, -1)(i => {
				if (s[i] === '?') s[i] = s[i+1] === 'R' ? 'B' : 'R'
			})
			ans = s.join('')
		}
		print(ans)
	})
}

var t = parseInt(readline())
while(t--){
    var n=parseInt(readline())
    var v=readline().split('')

    for(var i=n-2;~i;i--)
        if(v[i]==='?')
            v[i]= (v[i+1]==='R')?'B':'R'

    for(var i=1;i<n;i++)
        if(v[i]==='?')
            v[i]= (v[i-1]==='B')?'R':'B'

    var res=v.join('')
    if(res ==='?')res='B'
    print(res)
}

var readNumber = () => +readline();
var readStr = () => readline();
var n = readNumber();

for(var i = 0; i < n; i++) {
    readNumber();
    var array = readStr().split('');
    paint(array);
}

function paint(input){
    var firstPaintedIndex=1;
    adjacentColor="R";
    for(var index=0;index<input.length;index++){
        if(input[index]!='?'){
            firstPaintedIndex=index;
            adjacentColor=input[index];
            break;
        }
    }

    //paint left
    for(var index=firstPaintedIndex-1;index>=0;index--){
        input[index]=adjacentColor=='B'?'R':'B';
        adjacentColor=input[index];
    }

    adjacentColor=input[firstPaintedIndex]
    //paint right
    for(var index=firstPaintedIndex+1;index<input.length;index++){
        var current=input[index];
        if(current=='?'){
            input[index]=adjacentColor=='B'?'R':'B';
        }
        adjacentColor=input[index];
    }

    print(input.join(''));
}

'use strict'
Object.defineProperty(exports, '__esModule', { value: !0 })
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  lineIndex = 0
  lines = []
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const e = this.lines[this.lineIndex]
    return (this.lineIndex += 1), e
  }
  readLineAsNumber() {
    return Number(this.readLine())
  }
  readIntegersOfLine() {
    const e = this.readLine().match(integerRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  readNumsOfLine() {
    const e = this.readLine().match(decimalRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  print(e) {
    stdout.write(e)
  }
  async init() {
    const e = await this.readLines()
    this.lines = e
  }
  readLines() {
    const e = []
    return new Promise(n => {
      stdin.on('data', n => e.push(n)),
        stdin.on('end', function () {
          const t = e.join('').split(os.EOL)
          n(t)
        })
    })
  }
}
async function __main__(e) {
  const n = new InputAndOutput()
  await n.init(), e(n)
}
const regex = /([?]+)/g
function solve(e, n) {
  return n.replace(regex, (t, s, i) => {
    let r = 'R' === n[i] ? 'B' : 'R'
    if (i + s.length < e) {
      const e = n[i + s.length]
      r = 'R' === e ? (1 & s.length ? 'B' : 'R') : 1 & s.length ? 'R' : 'B'
    }
    const o = 'R' === r ? 'B' : 'R'
    return s
      .split('')
      .map((e, n) => (1 & n ? o : r))
      .join('')
  })
}
__main__(function (e) {
  const n = e.readLineAsNumber()
  for (let t = 1; t <= n; ++t) {
    const n = solve(e.readLineAsNumber(), e.readLine().trim())
    e.print(n + '\n')
  }
})

'use strict'
Object.defineProperty(exports, '__esModule', { value: !0 })
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  lineIndex = 0
  lines = []
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const e = this.lines[this.lineIndex]
    return (this.lineIndex += 1), e
  }
  readLineAsNumber() {
    return Number(this.readLine())
  }
  readIntegersOfLine() {
    const e = this.readLine().match(integerRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  readNumsOfLine() {
    const e = this.readLine().match(decimalRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  print(e) {
    stdout.write(e)
  }
  async init() {
    const e = await this.readLines()
    this.lines = e
  }
  readLines() {
    const e = []
    return new Promise(n => {
      stdin.on('data', n => e.push(n)),
        stdin.on('end', function () {
          const t = e.join('').split(os.EOL)
          n(t)
        })
    })
  }
}
async function __main__(e) {
  const n = new InputAndOutput()
  await n.init(), e(n)
}
const regex = /([?]+)/g
function solve(e, n) {
  return n.replace(regex, (t, s, i) => {
    let r = 'R' === s ? 'B' : 'R'
    if (i + s.length < e) {
      const e = n[i + s.length]
      r = 'R' === e ? (1 & s.length ? 'B' : 'R') : 1 & s.length ? 'R' : 'B'
    }
    const o = 'R' === r ? 'B' : 'R'
    return s
      .split('')
      .map((e, n) => (1 & n ? o : r))
      .join('')
  })
}
__main__(function (e) {
  const n = e.readLineAsNumber()
  for (let t = 1; t <= n; ++t) {
    const n = solve(e.readLineAsNumber(), e.readLine().trim())
    e.print(n + '\n')
  }
})

'use strict'
Object.defineProperty(exports, '__esModule', { value: !0 })
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  lineIndex = 0
  lines = []
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const e = this.lines[this.lineIndex]
    return (this.lineIndex += 1), e
  }
  readLineAsNumber() {
    return Number(this.readLine())
  }
  readIntegersOfLine() {
    const e = this.readLine().match(integerRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  readNumsOfLine() {
    const e = this.readLine().match(decimalRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  print(e) {
    stdout.write(e)
  }
  async init() {
    const e = await this.readLines()
    this.lines = e
  }
  readLines() {
    const e = []
    return new Promise(n => {
      stdin.on('data', n => e.push(n)),
        stdin.on('end', function () {
          const t = e.join('').split(os.EOL)
          n(t)
        })
    })
  }
}
async function __main__(e) {
  const n = new InputAndOutput()
  await n.init(), e(n)
}
function solve(e, n) {
  return n.replace(/([RB])?([?]+)/g, (e, n, t) => {
    const i = 'R' === n ? 'B' : 'R',
      s = 'R' === i ? 'B' : 'R'
    return (
      (n || '') +
      t
        .split('')
        .map((e, n) => (1 & n ? s : i))
        .join('')
    )
  })
}
__main__(function (e) {
  const n = e.readLineAsNumber()
  for (let t = 1; t <= n; ++t) {
    const n = solve(e.readLineAsNumber(), e.readLine().trim())
    e.print(n + '\n')
  }
})

'use strict'
Object.defineProperty(exports, '__esModule', { value: !0 })
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  lineIndex = 0
  lines = []
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const e = this.lines[this.lineIndex]
    return (this.lineIndex += 1), e
  }
  readLineAsNumber() {
    return Number(this.readLine())
  }
  readIntegersOfLine() {
    const e = this.readLine().match(integerRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  readNumsOfLine() {
    const e = this.readLine().match(decimalRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  print(e) {
    stdout.write(e)
  }
  async init() {
    const e = await this.readLines()
    this.lines = e
  }
  readLines() {
    const e = []
    return new Promise(n => {
      stdin.on('data', n => e.push(n)),
        stdin.on('end', function () {
          const t = e.join('').split(os.EOL)
          n(t)
        })
    })
  }
}
async function __main__(e) {
  const n = new InputAndOutput()
  await n.init(), e(n)
}
function solve(e, n) {
  return n.replace(/([RB])?([?]+)([RB])?/g, (e, n, t, i) => {
    if (null == n) {
      if (void 0 === i)
        return t
          .split('')
          .map((e, n) => (1 & n ? 'R' : 'B'))
          .join('')
      const e =
          'R' === i ? (1 & t.length ? 'B' : 'R') : 1 & t.length ? 'R' : 'B',
        n = 'R' === e ? 'B' : 'R'
      return (
        t
          .split('')
          .map((t, i) => (1 & i ? n : e))
          .join('') + i
      )
    }
    const s = 'R' === n ? 'B' : 'R',
      r = 'R' === s ? 'B' : 'R'
    return (
      n +
      t
        .split('')
        .map((e, n) => (1 & n ? r : s))
        .join('') +
      (i || '')
    )
  })
}
__main__(function (e) {
  const n = e.readLineAsNumber()
  for (let t = 1; t <= n; ++t) {
    const n = solve(e.readLineAsNumber(), e.readLine().trim())
    e.print(n + '\n')
  }
})


Consider all binary strings of length $$$m$$$ ($$$1 \le m \le 60$$$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $$$2^m$$$ such strings in total.The string $$$s$$$ is lexicographically smaller than the string $$$t$$$ (both have the same length $$$m$$$) if in the first position $$$i$$$ from the left in which they differ, we have $$$s[i] < t[i]$$$. This is exactly the way strings are compared in dictionaries and in most modern programming languages when comparing them in a standard way. For example, the string 01011 is lexicographically smaller than the string 01100, because the first two characters are the same, and the third character in the first string is less than that in the second.We remove from this set $$$n$$$ ($$$1 \le n \le \min(2^m-1, 100)$$$) distinct binary strings $$$a_1, a_2, \ldots, a_n$$$, each of length $$$m$$$. Thus, the set will have $$$k=2^m-n$$$ strings. Sort all strings of the resulting set in lexicographical ascending order (as in the dictionary).We number all the strings after sorting from $$$0$$$ to $$$k-1$$$. Print the string whose index is $$$\lfloor \frac{k-1}{2} \rfloor$$$ (such an element is called median), where $$$\lfloor x \rfloor$$$ is the rounding of the number down to the nearest integer.For example, if $$$n=3$$$, $$$m=3$$$ and $$$a=[$$$010, 111, 001$$$]$$$, then after removing the strings $$$a_i$$$ and sorting, the result will take the form: $$$[$$$000, 011, 100, 101, 110$$$]$$$. Thus, the desired median is 100.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then, $$$t$$$ test cases follow. The first line of each test case contains integers $$$n$$$ ($$$1 \le n \le \min(2^m-1, 100)$$$) and $$$m$$$ ($$$1 \le m \le 60$$$), where $$$n$$$ is the number of strings to remove, and $$$m$$$ is the length of binary strings. The next $$$n$$$ lines contain $$$a_1, a_2, \ldots, a_n$$$ — distinct binary strings of length $$$m$$$. The total length of all given binary strings in all test cases in one test does not exceed $$$10^5$$$.

Print $$$t$$$ answers to the test cases. For each test case, print a string of length $$$m$$$ — the median of the sorted sequence of remaining strings in the corresponding test case.

NoteThe first test case is explained in the statement.In the second test case, the result after removing strings and sorting is $$$[$$$001, 010, 101, 110$$$]$$$. Therefore, the desired median is 010.

function solve() {
    var nm = readIntArray()
    var n = nm[0]
    var m = nm[1]

    var curMid = "0"
    var j;
    for(j=1;j<m;j++){
        curMid+="1"
    }

    var k;
    var x = []
    for(k=0;k<n;k++){
        x.push(readline())
    }

    var i = 0
    var seen = {}
    while (i < n) {
        seen[x[i]] = true
        var size = (i + 1)
        if (x[i] == curMid) {
            if (size % 2 === 0) {
                curMid = minusOne(curMid, seen, m)
            } else {
                curMid = plusOne(curMid, seen, m)
            }
        } else {
            if (size % 2 !== 0 && x[i] < curMid) {
                curMid = plusOne(curMid, seen, m)
            } else if (size % 2 === 0 && x[i] > curMid) {
                curMid = minusOne(curMid, seen, m)
            }
        }

        i++
    }
    print(curMid)
}

function plusOne(curMid, x, m) {
    if (curMid.length > m) {
        return minusOne(curMid, x, m)
    }
    var i
    var lastZero = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "0") {
            lastZero = i
        }
    }
    if (lastZero == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastZero) + "1"
    var j;
    for(j=lastZero + 1;j<curMid.length;j++){
        newCurMid+="0"
    }
    if (x[newCurMid]) {
        return plusOne(newCurMid, x, m)
    }
    return newCurMid
}

function minusOne(curMid,x,m) {
    if (curMid.length > m) {
        return plusOne(curMid, x, m)
    }
    var i
    var lastOne = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "1") {
            lastOne = i
        }
    }
    if (lastOne == -1) {
        if (x[curMid]) {
            return plusOne(curMid, x, m)
        }
        return curMid
    }

    var newCurMid = curMid.substr(0, lastOne) + "0"
    var j;
    for(j=lastOne + 1;j<curMid.length;j++){
        newCurMid+="1"
    }
    if (x[newCurMid]) {
        return minusOne(newCurMid, x, m)
    }
    return newCurMid
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

function solve() {
    var nm = readIntArray()
    var n = nm[0]
    var m = nm[1]

    var curMid = "0"
    var j;
    for(j=1;j<m;j++){
        curMid+="1"
    }

    var k;
    var x = []
    for(k=0;k<n;k++){
        x.push(readline())
    }

    var i = 0
    var seen = []
    while (i < n) {
        if (seen.includes(x[i])) {
            i++
        } else {
            var size = Math.pow(2, m) - i
            if ((x[i] == curMid && size % 2 == 0) || x[i] < curMid) {
                curMid = plusOne(curMid)
            } else {
                curMid = minusOne(curMid)
            }
            if (!x.includes(curMid)) {
                i++
            } else {
                seen.push(curMid)
            }
        }
    }
    print(curMid)
}

function plusOne(curMid) {
    var i
    var lastZero = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "0") {
            lastZero = i
        }
    }
    if (lastZero == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastZero) + "1"
    var j;
    for(j=lastZero + 1;j<curMid.length;j++){
        newCurMid+="0"
    }
    return newCurMid
}

function minusOne(curMid) {
    var i
    var lastOne = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "1") {
            lastOne = i
        }
    }
    if (lastOne == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastOne) + "0"
    var j;
    for(j=lastOne + 1;j<curMid.length;j++){
        newCurMid+="1"
    }
    return newCurMid
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases && testCaseNum < 30; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

function solve() {
    var nm = readIntArray()
    var n = nm[0]
    var m = nm[1]

    var curMid = "0"
    var j;
    for(j=1;j<m;j++){
        curMid+="1"
    }

    var k;
    var x = []
    for(k=0;k<n;k++){
        x.push(readline())
    }

    var i = 0
    var seen = {}
    while (i < n) {
        seen[x[i]] = true
        var size = Math.pow(2, m) - (i + 1)
        if (x[i] == curMid) {
            if (size % 2 === 0) {
                curMid = minusOne(curMid, seen, m)
            } else {
                curMid = plusOne(curMid, seen, m)
            }
        } else {
            if (size % 2 !== 0 && x[i] < curMid) {
                curMid = plusOne(curMid, seen, m)
            } else if (size % 2 === 0 && x[i] > curMid) {
                curMid = minusOne(curMid, seen, m)
            }
        }
        print("CureMid: " + curMid)

        i++
    }
    print(curMid)
}

function plusOne(curMid, x, m) {
    if (curMid.length > m) {
        return minusOne(curMid)
    }
    var i
    var lastZero = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "0") {
            lastZero = i
        }
    }
    if (lastZero == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastZero) + "1"
    var j;
    for(j=lastZero + 1;j<curMid.length;j++){
        newCurMid+="0"
    }
    if (x[newCurMid]) {
        return plusOne(newCurMid, x, m)
    }
    return newCurMid
}

function minusOne(curMid,x,m) {
    if (curMid.length > m) {
        return plusOne(curMid)
    }
    var i
    var lastOne = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "1") {
            lastOne = i
        }
    }
    if (lastOne == -1) {

        if (x[curMid]) {
            return minusOne(curMid, x)
        }
        return curMid
    }

    var newCurMid = curMid.substr(0, lastOne) + "0"
    var j;
    for(j=lastOne + 1;j<curMid.length;j++){
        newCurMid+="1"
    }
    if (x[newCurMid]) {
        return minusOne(newCurMid, x)
    }
    return newCurMid
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

function solve() {
    var nm = readIntArray()
    var n = nm[0]
    var m = nm[1]

    var curMid = "0"
    var j;
    for(j=1;j<m;j++){
        curMid+="1"
    }

    var k;
    var x = []
    for(k=0;k<n;k++){
        x.push(readline())
    }

    var i = 0
    var seen = {}
    while (i < n) {
        seen[x[i]] = true
        var size = Math.pow(2, m) - (i + 1)
        if (x[i] == curMid) {
            if (size % 2 === 0) {
                curMid = minusOne(curMid, seen, m)
            } else {
                curMid = plusOne(curMid, seen, m)
            }
        } else {
            if (size % 2 !== 0 && x[i] < curMid) {
                curMid = plusOne(curMid, seen, m)
            } else if (size % 2 === 0 && x[i] > curMid) {
                curMid = minusOne(curMid, seen, m)
            }
        }

        i++
    }
    print(curMid)
}

function plusOne(curMid, x, m) {
    if (curMid.length > m) {
        return minusOne(curMid, x, m)
    }
    var i
    var lastZero = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "0") {
            lastZero = i
        }
    }
    if (lastZero == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastZero) + "1"
    var j;
    for(j=lastZero + 1;j<curMid.length;j++){
        newCurMid+="0"
    }
    if (x[newCurMid]) {
        return plusOne(newCurMid, x, m)
    }
    return newCurMid
}

function minusOne(curMid,x,m) {
    if (curMid.length > m) {
        return plusOne(curMid, x, m)
    }
    var i
    var lastOne = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "1") {
            lastOne = i
        }
    }
    if (lastOne == -1) {

        if (x[curMid]) {
            return plusOne(curMid, x, m)
        }
        return curMid
    }

    var newCurMid = curMid.substr(0, lastOne) + "0"
    var j;
    for(j=lastOne + 1;j<curMid.length;j++){
        newCurMid+="1"
    }
    if (x[newCurMid]) {
        return minusOne(newCurMid, x, m)
    }
    return newCurMid
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

function solve() {
    var nm = readIntArray()
    var n = nm[0]
    var m = nm[1]

    var curMid = "0"
    var j;
    for(j=1;j<m;j++){
        curMid+="1"
    }

    var k;
    var x = []
    for(k=0;k<n;k++){
        x.push(readline())
    }

    var i = 0
    var seen = {}
    while (i < n) {
        seen[x[i]] = true
        var size = Math.pow(2, m) - (i + 1)
        if (x[i] == curMid) {
            if (size % 2 === 0) {
                curMid = minusOne(curMid, seen, m)
            } else {
                curMid = plusOne(curMid, seen, m)
            }
        } else {
            if (size % 2 !== 0 && x[i] < curMid) {
                curMid = plusOne(curMid, seen, m)
            } else if (size % 2 === 0 && x[i] > curMid) {
                curMid = minusOne(curMid, seen, m)
            }
        }

        i++
    }
    print(curMid)
}

function plusOne(curMid, x, m) {
    if (curMid.length > m) {
        return minusOne(curMid)
    }
    var i
    var lastZero = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "0") {
            lastZero = i
        }
    }
    if (lastZero == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastZero) + "1"
    var j;
    for(j=lastZero + 1;j<curMid.length;j++){
        newCurMid+="0"
    }
    if (x[newCurMid]) {
        return plusOne(newCurMid, x, m)
    }
    return newCurMid
}

function minusOne(curMid,x,m) {
    if (curMid.length > m) {
        return plusOne(curMid)
    }
    var i
    var lastOne = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "1") {
            lastOne = i
        }
    }
    if (lastOne == -1) {

        if (x[curMid]) {
            return minusOne(curMid, x)
        }
        return curMid
    }

    var newCurMid = curMid.substr(0, lastOne) + "0"
    var j;
    for(j=lastOne + 1;j<curMid.length;j++){
        newCurMid+="1"
    }
    if (x[newCurMid]) {
        return minusOne(newCurMid, x)
    }
    return newCurMid
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

function solve() {
    var nm = readIntArray()
    var n = nm[0]
    var m = nm[1]

    var curMid = "0"
    var j;
    for(j=1;j<m;j++){
        curMid+="1"
    }

    var k;
    var x = []
    for(k=0;k<n;k++){
        x.push(readline())
    }

    var i = 0
    var max = Math.pow(2, m) - 1
    var seen = {}
    while (i < n) {
        seen[x[i]] = true
        var size = Math.pow(2, m) - i + 1
        if (x[i] == curMid) {
            if (size % 2 === 0) {
                curMid = minusOne(curMid, seen, m)
            } else {
                curMid = plusOne(curMid, seen, m)
            }
        } else {
            if (size % 2 !== 0 && x[i] < curMid) {
                curMid = plusOne(curMid, seen, m)
            } else if (size % 2 === 0 && x[i] > curMid) {
                curMid = minusOne(curMid, seen, m)
            }
        }

        i++
    }
    print(curMid)
}

function plusOne(curMid, x, m) {
    if (curMid.length > m) {
        return minusOne(curMid)
    }
    var i
    var lastZero = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "0") {
            lastZero = i
        }
    }
    if (lastZero == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastZero) + "1"
    var j;
    for(j=lastZero + 1;j<curMid.length;j++){
        newCurMid+="0"
    }
    if (x[newCurMid]) {
        return plusOne(newCurMid, x, m)
    }
    return newCurMid
}

function minusOne(curMid,x,m) {
    if (curMid.length > m) {
        return plusOne(curMid)
    }
    var i
    var lastOne = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "1") {
            lastOne = i
        }
    }
    if (lastOne == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastOne) + "0"
    var j;
    for(j=lastOne + 1;j<curMid.length;j++){
        newCurMid+="1"
    }
    if (x[newCurMid]) {
        return minusOne(newCurMid, x)
    }
    return newCurMid
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases && testCaseNum < 30; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

function solve() {
    var nm = readIntArray()
    var n = nm[0]
    var m = nm[1]

    var curMid = "0"
    var j;
    for(j=1;j<m;j++){
        curMid+="1"
    }

    var k;
    var x = []
    for(k=0;k<n;k++){
        x.push(readline())
    }

    var i = 0
    var max = Math.pow(2, m) - 1
    var seen = {}
    while (i < n) {
        seen[x[i]] = true
        var size = Math.pow(2, m) - i + 1
        if (x[i] == curMid) {
            if (size % 2 === 0) {
                curMid = minusOne(curMid, seen)
            } else {
                curMid = plusOne(curMid, seen)
            }
        } else {
            if (size % 2 !== 0 && x[i] < curMid) {
                curMid = plusOne(curMid, seen)
            } else if (size % 2 === 0 && x[i] > curMid) {
                curMid = minusOne(curMid, seen)
            }
        }

        i++
    }
    print(curMid)
}

function plusOne(curMid, x, max) {
    if (curMid > max) {
        return minusOne(curMid)
    }
    var i
    var lastZero = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "0") {
            lastZero = i
        }
    }
    if (lastZero == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastZero) + "1"
    var j;
    for(j=lastZero + 1;j<curMid.length;j++){
        newCurMid+="0"
    }
    if (x[newCurMid]) {
        return plusOne(newCurMid, x, max)
    }
    return newCurMid
}

function minusOne(curMid,x) {
    if (curMid == -1) {
        return plusOne(curMid)
    }
    var i
    var lastOne = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "1") {
            lastOne = i
        }
    }
    if (lastOne == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastOne) + "0"
    var j;
    for(j=lastOne + 1;j<curMid.length;j++){
        newCurMid+="1"
    }
    if (x[newCurMid]) {
        return minusOne(newCurMid, x)
    }
    return newCurMid
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases && testCaseNum < 30; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

function solve() {
    var nm = readIntArray()
    var n = nm[0]
    var m = nm[1]

    var curMid = "0"
    var j;
    for(j=1;j<m;j++){
        curMid+="1"
    }

    var k;
    var x = []
    for(k=0;k<n;k++){
        x.push(readline())
    }

    var i = 0
    var max = Math.pow(2, m) - 1
    var seen = {}
    while (i < n) {
        seen[x[i]] = true
        var size = Math.pow(2, m) - i + 1
        if (x[i] == curMid) {
            if (size % 2 === 0) {
                curMid = minusOne(curMid, seen, m)
            } else {
                curMid = plusOne(curMid, seen, m)
            }
        } else {
            if (size % 2 !== 0 && x[i] < curMid) {
                curMid = plusOne(curMid, seen, m)
            } else if (size % 2 === 0 && x[i] > curMid) {
                curMid = minusOne(curMid, seen, m)
            }
        }

        i++
    }
    print(curMid)
}

function plusOne(curMid, x, m) {
    if (curMid.length > m) {
        return minusOne(curMid)
    }
    var i
    var lastZero = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "0") {
            lastZero = i
        }
    }
    if (lastZero == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastZero) + "1"
    var j;
    for(j=lastZero + 1;j<curMid.length;j++){
        newCurMid+="0"
    }
    if (x[newCurMid]) {
        return plusOne(newCurMid, x, m)
    }
    return newCurMid
}

function minusOne(curMid,x,m) {
    if (curMid.length > m) {
        return plusOne(curMid)
    }
    var i
    var lastOne = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "1") {
            lastOne = i
        }
    }
    if (lastOne == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastOne) + "0"
    var j;
    for(j=lastOne + 1;j<curMid.length;j++){
        newCurMid+="1"
    }
    if (x[newCurMid]) {
        return minusOne(newCurMid, x)
    }
    return newCurMid
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

function solve() {
    var nm = readIntArray()
    var n = nm[0]
    var m = nm[1]

    var curMid = "0"
    var j;
    for(j=1;j<m;j++){
        curMid+="1"
    }

    var k;
    var x = []
    for(k=0;k<n;k++){
        x.push(readline())
    }

    var i = 0
    var seen = []
    while (i < n) {
        var size = Math.pow(2, m) - i + 1
        if (x[i] == curMid) {
            if (size % 2 === 0) {
                curMid = minusOne(curMid)
            } else {
                curMid = plusOne(curMid)
            }
        } else {
            if (size % 2 !== 0 && x[i] < curMid) {
                curMid = plusOne(curMid)
            } else if (size % 2 === 0 && x[i] > curMid) {
                curMid = minusOne(curMid)
            }
        }

        i++
    }
    print(curMid)
}

function plusOne(curMid) {
    var i
    var lastZero = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "0") {
            lastZero = i
        }
    }
    if (lastZero == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastZero) + "1"
    var j;
    for(j=lastZero + 1;j<curMid.length;j++){
        newCurMid+="0"
    }
    return newCurMid
}

function minusOne(curMid) {
    var i
    var lastOne = -1
    var split = curMid.split("")
    for(i=0; i<curMid.length; i++) {
        if (split[i] === "1") {
            lastOne = i
        }
    }
    if (lastOne == -1) {
        return curMid
    }

    var newCurMid = curMid.substr(0, lastOne) + "0"
    var j;
    for(j=lastOne + 1;j<curMid.length;j++){
        newCurMid+="1"
    }
    return newCurMid
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases && testCaseNum < 30; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}


Sometimes it is not easy to come to an agreement in a bargain. Right now Sasha and Vova can't come to an agreement: Sasha names a price as high as possible, then Vova wants to remove as many digits from the price as possible. In more details, Sasha names some integer price $$$n$$$, Vova removes a non-empty substring of (consecutive) digits from the price, the remaining digits close the gap, and the resulting integer is the price.For example, is Sasha names $$$1213121$$$, Vova can remove the substring $$$1312$$$, and the result is $$$121$$$.It is allowed for result to contain leading zeros. If Vova removes all digits, the price is considered to be $$$0$$$.Sasha wants to come up with some constraints so that Vova can't just remove all digits, but he needs some arguments supporting the constraints. To start with, he wants to compute the sum of all possible resulting prices after Vova's move.Help Sasha to compute this sum. Since the answer can be very large, print it modulo $$$10^9 + 7$$$.

The first and only line contains a single integer $$$n$$$ ($$$1 \le n < 10^{10^5}$$$).

In the only line print the required sum modulo $$$10^9 + 7$$$.

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

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) 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 ? fn(v) : 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];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

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

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = 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, m] = $(2), res = 0
  //   let a = Arr(n, i => $(m))
  //   // log(a)
  //   For((n + 1) / 2 | 0, i => {
  //     For((m + 1) / 2 | 0, j => {
  //       let a1 = a[i][j], a2 = a[n - 1 - i][j], a3 = a[i][m - 1 - j], a4 = a[n - 1 - i][m - 1 - j];
  //       // log(i, j, a1, a2, a3, a4)
  //       let tb = Math.round((a1 + a2 + a3 + a4) / 4)
  //       let s = abs(a1 - tb) + abs(a2 - tb) + abs(a3 - tb) + abs(a4 - tb);
  //       if (i == n - 1 - i || j == m - 1 - j) s /= 2;
  //       res += s;
  //     })
  //   })
  //   log(res)
  // }
  let MOD = 1e9 + 7;
  let s = $()
  let n = s.length
  let f = Arr(n, i => 0), g = Arr(n, i => 0), cur;
  f[0] = +s[0]
  cur = +s[0]
  For(1, n - 1, i => {
    g[i] = (g[i - 1] + cur) % MOD;
    f[i] = (f[i - 1] * 10 + (i * (i + 1) / 2 + 1) * s[i] + g[i]) % MOD
    cur = (cur * 10 + +s[i]) % MOD;
  })
  log((MOD + f[n - 1] - cur % MOD) % MOD)
}


Orac is studying number theory, and he is interested in the properties of divisors.For two positive integers $$$a$$$ and $$$b$$$, $$$a$$$ is a divisor of $$$b$$$ if and only if there exists an integer $$$c$$$, such that $$$a\cdot c=b$$$.For $$$n \ge 2$$$, we will denote as $$$f(n)$$$ the smallest positive divisor of $$$n$$$, except $$$1$$$.For example, $$$f(7)=7,f(10)=2,f(35)=5$$$.For the fixed integer $$$n$$$, Orac decided to add $$$f(n)$$$ to $$$n$$$. For example, if he had an integer $$$n=5$$$, the new value of $$$n$$$ will be equal to $$$10$$$. And if he had an integer $$$n=6$$$, $$$n$$$ will be changed to $$$8$$$.Orac loved it so much, so he decided to repeat this operation several times.Now, for two positive integers $$$n$$$ and $$$k$$$, Orac asked you to add $$$f(n)$$$ to $$$n$$$ exactly $$$k$$$ times (note that $$$n$$$ will change after each operation, so $$$f(n)$$$ may change too) and tell him the final value of $$$n$$$.For example, if Orac gives you $$$n=5$$$ and $$$k=2$$$, at first you should add $$$f(5)=5$$$ to $$$n=5$$$, so your new value of $$$n$$$ will be equal to $$$n=10$$$, after that, you should add $$$f(10)=2$$$ to $$$10$$$, so your new (and the final!) value of $$$n$$$ will be equal to $$$12$$$.Orac may ask you these queries many times.

The first line of the input is a single integer $$$t\ (1\le t\le 100)$$$: the number of times that Orac will ask you. Each of the next $$$t$$$ lines contains two positive integers $$$n,k\ (2\le n\le 10^6, 1\le k\le 10^9)$$$, corresponding to a query by Orac. It is guaranteed that the total sum of $$$n$$$ is at most $$$10^6$$$.

Print $$$t$$$ lines, the $$$i$$$-th of them should contain the final value of $$$n$$$ in the $$$i$$$-th query by Orac.

NoteIn the first query, $$$n=5$$$ and $$$k=1$$$. The divisors of $$$5$$$ are $$$1$$$ and $$$5$$$, the smallest one except $$$1$$$ is $$$5$$$. Therefore, the only operation adds $$$f(5)=5$$$ to $$$5$$$, and the result is $$$10$$$.In the second query, $$$n=8$$$ and $$$k=2$$$. The divisors of $$$8$$$ are $$$1,2,4,8$$$, where the smallest one except $$$1$$$ is $$$2$$$, then after one operation $$$8$$$ turns into $$$8+(f(8)=2)=10$$$. The divisors of $$$10$$$ are $$$1,2,5,10$$$, where the smallest one except $$$1$$$ is $$$2$$$, therefore the answer is $$$10+(f(10)=2)=12$$$.In the third query, $$$n$$$ is changed as follows: $$$3 \to 6 \to 8 \to 10 \to 12$$$.

'use strict';

const parseProblem = (line, problem) => {
    if (!problem.T || problem.T === 0) {
        problem.T = parseInt(line);
        return problem;
    }

    const cases = problem.cases;

    //if (cases.length === 0 || cases[cases.length - 1].arr) {
        cases.push({
            t: line
        });
    /*} else {
        cases[cases.length - 1].arr = line;
    }*/

    const isProcessing = cases.length < problem.T;// || !cases[cases.length - 1].arr;
    problem.isProcessing = isProcessing;

    return problem;
};

const solve = data => {
    const [n, k] = data.t.split(' ').map(i => +i);
    let num = n;
    let i = 1;

    num += f(num);
    num += (k - 1) * 2;

    return num;
}

const f = n => {
    for(let i = 2; i <= Math.pow(n, 2); i++) {
        if(n % i == 0) return i;
    }
    return n;
}

const solveCases = cases => {
    for (let index = 0; index < cases.length; index++) {
        const result = solve(cases[index]);
        console.log(result);
    }
};

const main = () => {
    const readline = require('readline');

    let problem = {
        T: 0,
        cases: [],
        isProcessing: true
    };

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

    rl.on('line', line => {
        problem = parseProblem(line, problem);

        if (!problem.isProcessing) {
            rl.close();
        }
    }).on('close', () => {
        solveCases(problem.cases);
        process.exit(0);
    });
};

if (!module.parent) {
    main();
}

const readline = require('readline');

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

let tests = [];
rl.on('line', (line) => {
  tests.push(line.split(' '));
}).on('close', () => {
  for (i = 1; i < tests.length; i++) {

    const getMinDel = (ch) => {
      if (ch % 2 === 0) {
        return 2
      } else if (ch % 3 === 0) {
        return 3
      } else if (ch % 5 === 0) {
        return 5
      } else if (ch % 7 === 0) {
        return 7
      } else {
        for (x = 11; x <= ch; x++) {
          if (ch % x === 0) {
            return x;
          }
        }
      };
    }

    const k = +tests[i][1] - 1;
    let n = +tests[i][0] + getMinDel(+tests[i][0]);

    process.stdout.write(`${n + (2 * k)}\n`);
  }
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let ans = '';

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

  let [n, k] = d.split(' ').map(Number);

  for (let i = 2; i <= n; i++) {
    if (n % i === 0) {
      n += i;
      break;
    }
  }
  k--;

  n += k * 2;

  ans += `${n}\n`;

  c++;
});

rl.on('close', () => {
  console.log(ans);
});

'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++];
}
/**
  3
5 1
8 2
3 4

**/

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

    for(let r=0;r<range;r++) {
        let [n,k] = readline().split(" ").map(Number);

        let count = 0;

        for(let i=2;i<=n;i++) {
            if( n % i === 0) {
                n+=i;
                break;
            }
        }

        console.log( n + (2 * (k - 1)));
    }

}

'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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let c = parseInt(readLine());
    for (var j = 0; j < c; j++) {
        let arr = readLine()
            .split(' ')
            .map(value => parseInt(value))
        var n = arr[0];
        var k = arr[1];
        // console.log("n vs k: ", n, k);
        if (n % 2 == 0) {
            console.log(n + 2 * k);
        } else {
            let f = 0;
            for (var i = 2; i * i <= n; i++) {
                if (n % i == 0) {
                    n += i;
                    f = 1;
                    break;
                }
            }
            // console.log("f: ", f);
            if (f == 0) {
                n += n;
            };
            console.log(n + (k - 1) * 2);
        }
    }
}

function divisors(n, k) {
  if (n % 2 != 0) {
    var divisor;
    for (var i = 2; i <= n; i++) {
      if (n % i == 0) {
        divisor = i;
        break;
      }
    }
    n += divisor;
    k--;

    n += 2 * k;
  } else {
    n += 2 * k;
  }
  return n;
}
var t = parseInt(readline());

for (var tc = 0; tc < t; tc++) {
  var nk = readline()
    .split(" ")
    .map((val) => parseInt(val));
  var n = nk[0],
    k = nk[1];
  var res = divisors(n, k);
  print(res);
}

var t = Number(readline());
var inp;
for(var i = 0; i < t ; i++){
    inp = readline().split(' ').map(cur => Number(cur));
        for (var j = 2; j <= inp[0] ; j++){
            if(inp[0]%j === 0) break;
        }
        print(inp[0] + j + 2*(inp[1] - 1));
    }

const readline = require('readline');

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

let tests = [];
rl.on('line', (line) => {
  tests.push(line.split(' '));
}).on('close', () => {
  for (i = 1; i < tests.length; i++) {

    const getMinDel = (ch) => {
      for (j = 2; j <= 9; j++) {
        if (ch % j === 0) {
          return j;
        }
      }
    }

    const k = +tests[i][1];
    let newN = +tests[i][0] + getMinDel(+tests[i][0]);

    process.stdout.write(`${newN + 2 * (k - 1)}\n`);
  }
});

const readline = require('readline');

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

let tests = [];
rl.on('line', (line) => {
  tests.push(line.split(' '));
}).on('close', () => {
  for (i = 1; i < tests.length; i++) {

    const getMinDel = (ch) => {
      for (j = 2; j <= 9; j++) {
        if (ch % j === 0) return j;
      }
    }

    const k = +tests[i][1] - 1;
    let n = +tests[i][0] + getMinDel(+tests[i][0]);

    process.stdout.write(`${n + (2 * k)}\n`);
  }
});

const readline = require('readline');

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

let tests = [];
rl.on('line', (line) => {
  tests.push(line.split(' '));
}).on('close', () => {
  for (i = 1; i < tests.length; i++) {

    const getMinDel = (ch) => {
      if (ch % 2 === 0) {
        return 2
      } else if (ch % 3 === 0) {
        return 3
      } else if (ch % 5 === 0) {
        return 5
      } else if (ch % 7 === 0) {
        return 7
      } else {
        return ch;
      }
    }

    const k = +tests[i][1] - 1;
    let n = +tests[i][0] + getMinDel(+tests[i][0]);

    process.stdout.write(`${n + (2 * k)}\n`);
  }
});

const readline = require('readline');

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

let tests = [];
rl.on('line', (line) => {
  tests.push(line.split(' '));
}).on('close', () => {
  for (i = 1; i < tests.length; i++) {

    const getMinDel = (ch) => {
      if (ch % 2 === 0) return 2;
      if (ch < 10) return ch;
      if (ch % 3 === 0) return 3;
      if (ch % 5 === 0) return 5;
    }

    const k = +tests[i][1];
    let newN = +tests[i][0] + getMinDel(tests[i][0]);

    process.stdout.write(`${newN + 2 * k - 1}\n`);
  }
});

const readline = require('readline');

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

let tests = [];
rl.on('line', (line) => {
  tests.push(line.split(' '));
}).on('close', () => {
  for (i = 1; i < tests.length; i++) {

    const getMinDel = (ch) => {
      if (ch % 2 === 0) return 2;
      if (ch < 10) return ch;
      if (ch % 3 === 0) return 3;
      if (ch % 5 === 0) return 5;
    }

    const k = +tests[i][1];
    let newN = +tests[i][0] + getMinDel(+tests[i][0]);

    process.stdout.write(`${newN + 2 * (k - 1)}\n`);
  }
});

'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++];
}
/**
  3
5 1
8 2
3 4

**/

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

    for(let r=0;r<range;r++) {
        let [x, y] = readline().split(" ").map(Number);

        if(x % y === 0) {
            console.log(x + (x / y));
        } else {
            console.log(x*y);
        }
    }

}

'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++];
}
/**
  3
5 1
8 2
3 4

**/

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

    for(let r=0;r<range;r++) {
        let [x, y] = readline().split(" ").map(Number);

        if(x % y === 0) {
            console.log(x + (x / y));
        } else {
            console.log(x *  y + (Math.floor(x/y)));
        }
    }

}

var t = Number(readline());
var inp;
for(var i = 0; i < t ; i++){
    inp = readline().split(' ').map(cur => Number(cur));
    if (inp[0]%2 === 0){
        print(inp[0] + 2*inp[1])
    }else{
        var d = inp[0];
        for (var j = 3; j <= Math.sqrt(inp[0]); j += 2){
            (inp[0]%j === 0) ? d = j : null;
        }
        print(inp[0] + d + 2*(inp[1] - 1));
    }
}


The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding the boundaries of the city.The city of Tomsk can be represented as point on the plane with coordinates (0; 0). The city is surrounded with n other locations, the i-th one has coordinates (xi, yi) with the population of ki people. You can widen the city boundaries to a circle of radius r. In such case all locations inside the circle and on its border are included into the city.Your goal is to write a program that will determine the minimum radius r, to which is necessary to expand the boundaries of Tomsk, so that it becomes a megacity.

The first line of the input contains two integers n and s (1 ≤ n ≤ 103; 1 ≤ s < 106) — the number of locatons around Tomsk city and the population of the city. Then n lines follow. The i-th line contains three integers — the xi and yi coordinate values of the i-th location and the number ki of people in it (1 ≤ ki < 106). Each coordinate is an integer and doesn't exceed 104 in its absolute value. It is guaranteed that no two locations are at the same point and no location is at point (0; 0).

In the output, print "-1" (without the quotes), if Tomsk won't be able to become a megacity. Otherwise, in the first line print a single real number — the minimum radius of the circle that the city needs to expand to in order to become a megacity. The answer is considered correct if the absolute or relative error don't exceed 10 - 6.

print(function() {
    var data = rn();
    var n = data[0];
    var s = data[1];
    var cities=[];
    for(var i=0; i<n; ++i) {
        data = rn();
        var x = data[0];
        var y = data[1];
        var k = data[2];
        cities.push({key1 : x*x+y*y, key2 : k});
    }
    cities.sort(function(a, b){
        return a.key1-b.key1
    });
    var sum=s;
    for(var i=0; i<cities.length; ++i) {
        sum+=cities[i].key2;
        if(sum>=1000000) {
            return Math.sqrt(cities[i].key1);

        }
    }
    return -1;
}());
function rn() {
    return readline().split(' ').map(Number);
}

print(function() {
    var data = rn();
    var n = data[0];
    var s = data[1];
    var cities=[];
    for(var i=0; i<n; ++i) {
        data = rn();
        var x = data[0];
        var y = data[1];
        var k = data[2];
        cities.push({key1 : x*x+y*y, key2 : k});
    }
    cities.sort(function(a, b) {
        return a.key1-b.key1;
    });
    var sum=s;
    for(var i=0; i<n; ++i) {
        sum+=cities[i].key2;
        if(sum>=1000000) {
            return Math.sqrt(cities[i].key1);
        }
    }
    return -1;
}());
function rn() {
    return readline().split(' ').map(Number);
}

print(function() {
    var data = rn();
    var n = data[0];
    var s = data[1];
    var cities=[];
    for(var i=0; i<n; ++i) {
        data = rn();
        var x = data[0];
        var y = data[1];
        var k = data[2];
        cities.push([ x*x+y*y,  k]);
    }
    cities.sort(function(a, b){
        return a[0]-b[0];
    });
    var sum=s;
    for(var i=0; i<cities.length; ++i) {
        sum+=cities[i][1];
        if(sum>=1000000) {
            return Math.sqrt(cities[i][0]);

        }
    }
    return -1;
}());
function rn() {
    return readline().split(' ').map(Number);
}

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], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline());
	var numCities = data[0], totalPopulation = data[1];
	var cities = [];
	for (var i = 0; i < numCities; ++i) {
		data = tokenizeIntegers(readline());
		var x = data[0], y = data[1], population = data[2];
		cities.push({ distanceSquared: x*x + y*y, population: population });
	}
	cities.sort(function (a, b) {
		return a.distanceSquared - b.distanceSquared;
	});
	for (var i = 0; i < cities.length; ++i) {
		totalPopulation += cities[i].population;
		if (totalPopulation >= 1000000) {
			print(Math.sqrt(cities[i].distanceSquared));
			return;
		}
	}
	print(-1);
}

main();

function main() {

    var first = readline().split(' ').map(Number);
    var n=first[0],s=first[1];
    var arr=[];
    for(var m=0;m<n;m++){
        var second = readline().split(' ').map(Number);
        arr.push(second);
    }

    var newarr=[];
    for(var j=0;j<n;j++){
        var temp=[];
        temp.push(Math.sqrt(Math.pow(arr[j][0],2)+Math.pow(arr[j][1],2)));
        temp.push(arr[j][2]);

        newarr.push(temp);
    }

    newarr.sort(sortFunction);

    function sortFunction(a, b) {
        if (a[0] === b[0]) {
            return 0;
        }
        else {
            return (a[0] < b[0]) ? -1 : 1;
        }
    }

    var sum=0;
    for(var i=0;i<n;i++){
        sum+=newarr[i][1];
    }

    if((sum+s)<1000000){
        print(-1);
    }else {
        for( j=0;j<n;j++){
            s+=newarr[j][1];
            if(s>=1000000){
                print(newarr[j][0]);
                break;
            }
        }
    }
}

main();

var firstLine = readline().split(" ").map(Number);
var n = firstLine[0];
var s = firstLine[1];

function city(x, y, p){
	this.x = x
	this.y = y
	this.p = p
	this.distance = function(){return Math.sqrt(this.x*this.x + this.y*this.y)}
}

// city.prototype.distance = function(){
// 	return Math.sqrt(this.x*this.x + this.y*this.y)
// }

var cities = []

for(i = 0; i < n; i++){
	data = readline().split(" ").map(Number);
	cities.push(new city(data[0], data[1], data[2]))
}

cities.sort(function(a,b){return a.distance() - b.distance()})

var notMega = true
var myDistance = 0

while(notMega && cities.length !== 0 ){
	nextCity = cities.shift()
	s += nextCity.p
	if(s >= 1000000){
		notMega = false
		myDistance = nextCity.distance()
	}
}

if(notMega){
	print(-1)
}
else{
	print(myDistance)
}

print(function() {
    var data = rn();
    var n = data[0];
    var s = data[1];
    var cities=[];
    for(var i=0; i<n; ++i) {
        data = rn();
        var x = data[0];
        var y = data[1];
        var k = data[2];
        cities.push([x*x+y*y, k]);
    }
    cities.sort(function(a, b) {
        return a[0]-b[0];
    });
    var sum=s;
    for(var i=0; i<n; ++i) {
        sum+=cities[i][1];
        if(sum>=1000000) {
            return Math.sqrt(cities[i][0]);
        }
    }
    return -1;
}());
function rn() {
    return readline().split(' ').map(Number);
}

print(function() {
    var data = rn();
    var n = data[0];
    var s = data[1];
    var cities=[];
    for(var i=0; i<n; ++i) {
        data = rn();
        var x = data[0];
        var y = data[1];
        var k = data[2];
        cities.push([ (x*x+y*y,  k)]);
    }
    cities.sort(function(a, b){
        return a[0]-b[0];
    });
    var sum=s;
    for(var i=0; i<cities.length; ++i) {
        sum+=cities[i][1];
        if(sum>=1000000) {
            return Math.sqrt(cities[i][0]);

        }
    }
    return -1;
}());
function rn() {
    return readline().split(' ').map(Number);
}

print(function() {
    var data = rn();
    var n = data[0];
    var s = data[1];
    var cities=[];
    for(var i=0; i<n; ++i) {
        data = rn();
        var x = data[0];
        var y = data[1];
        var k = data[2];
        cities.push({key1 : x*x+y*y, key2 : k});
    }
    cities.sort(function(a, b){
        return a.key1-b.key1
    });
    var sum=s;
    for(var i=0; i<cities.length; ++i) {
        sum+=cities[i].key2;
        if(sum>=1000000) {
            print(Math.sqrt(cities[i].key1));
            return;
        }
    }
    print(-1);
}());
function rn() {
    return readline().split(' ').map(Number);
}

print(function() {
    var n = +readline();
    var s = +readline();
    var cities=[];
    for(var i=0; i<n; ++i) {
        var data = rn();
        var x = data[0];
        var y = data[1];
        var k = data[2];
        cities.push({key1 : x*x+y*y, key2 : k});
    }
    cities.sort(function(a, b){
        return a.key1-b.key1
    });
    var sum=s;
    for(var i=0; i<cities.length; ++i) {
        sum+=cities[i].key2;
        if(sum>=1000000) {
            print(Math.sqrt(cities[i].key1));
            return;
        }
    }
    print(-1);
}());
function rn() {
    return readline().split(' ').map(Number);
}

print(function() {
    var n = +readline();
    var s = +readline();
    var cities=[];
    for(var i=0; i<n; ++i) {
        var x = +readline();
        var y = +readline();
        var k = +readline();
        cities.push({key1 : x*x+y*y, key2 : k});
    }
    cities.sort(function(a, b){
        return a.key1-b.key1
    });
    var sum=s;
    for(var i=0; i<cities.length; ++i) {
        sum+=cities[i].key2;
        if(sum>=1000000) {
            print(Math.sqrt(cities[i].key1));
            return;
        }
    }
    print(-1);
}());
function rn() {
    return readline().split(' ').map(Number);
}

function main() {

    var first = readline().split(' ').map(Number);
    var n=first[0],s=first[1];
    var arr=[];
    for(var m=0;m<n;m++){
        var second = readline().split(' ').map(Number);
        arr.push(second);
    }

    var newarr=[];
    for(var j=0;j<n;j++){
        var temp=[];
        temp.push(Math.sqrt(Math.pow(arr[j][0],2)+Math.pow(arr[j][1],2)));
        temp.push(arr[j][2]);

        newarr.push(temp);
    }

    newarr.sort(sortFunction);

    function sortFunction(a, b) {
        if (a[0] === b[0]) {
            return 0;
        }
        else {
            return (a[0] < b[0]) ? -1 : 1;
        }
    }

    var sum=0;
    for(var i=0;i<n;i++){
        sum+=newarr[i][1];
    }

    if((sum+s)<1000000){
        print(-1);
    }else {
        for( j=0;j<n;j++){
            s+=newarr[j][1];
            if(s>1000000){
                print(newarr[j][0]);
                break;
            }
        }
    }
}

main();

var firstLine = readline().split(" ").map(Number);
var n = firstLine[0];
var s = firstLine[1];

function city(x, y, p){
	this.x = x
	this.y = y
	this.p = p
	this.distance = function(){return Math.sqrt(this.x*this.x + this.y*this.y)}
}

// city.prototype.distance = function(){
// 	return Math.sqrt(this.x*this.x + this.y*this.y)
// }

var cities = []

for(i = 0; i < n; i++){
	data = readline().split(" ").map(Number);
	cities.push(new city(data[0], data[1], data[2]))
}

cities.sort(function(a,b){return a.distance - b.distance})

var notMega = true
var myDistance = 0

while(notMega && cities.length !== 0 ){
	nextCity = cities.shift()
	s += nextCity.p
	if(s >= 1000000){
		notMega = false
		myDistance = nextCity.distance()
	}
}

if(notMega){
	print(-1)
}
else{
	print(myDistance)
}


The only difference between this problem and D1 is that you don't have to provide the way to construct the answer in D1, but you have to do it in this problem.There's a table of $$$n \times m$$$ cells ($$$n$$$ rows and $$$m$$$ columns). The value of $$$n \cdot m$$$ is even.A domino is a figure that consists of two cells having a common side. It may be horizontal (one of the cells is to the right of the other) or vertical (one of the cells is above the other).You need to place $$$\frac{nm}{2}$$$ dominoes on the table so that exactly $$$k$$$ of them are horizontal and all the other dominoes are vertical. The dominoes cannot overlap and must fill the whole table.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case consists of a single line. The line contains three integers $$$n$$$, $$$m$$$, $$$k$$$ ($$$1 \le n,m \le 100$$$, $$$0 \le k \le \frac{nm}{2}$$$, $$$n \cdot m$$$ is even) — the count of rows, columns and horizontal dominoes, respectively.

For each test case:   print "NO" if it's not possible to place the dominoes on the table in the described way;  otherwise, print "YES" on a separate line, then print $$$n$$$ lines so that each of them contains $$$m$$$ lowercase letters of the Latin alphabet — the layout of the dominoes on the table. Each cell of the table must be marked by the letter so that for every two cells having a common side, they are marked by the same letters if and only if they are occupied by the same domino. I.e. both cells of the same domino must be marked with the same letter, but two dominoes that share a side must be marked with different letters. If there are multiple solutions, print any of them.

YES
accx
aegx
bega
bdda
YES
aha
aha
YES
zz
aa
zz
NO
YES
aaza
bbza
NO
YES
bbaabbaabbaabbaay
ddccddccddccddccy
NO

'use strict';

function solve(n, m, k) {
  let res = Array.from({
    length: n
  }, () => new Array(m));
  let odd = 0;
  const next = (...args) => {
    const set = new Set(args);
    for (let i = 0; i < 26; i++) {
      if (!set.has(i)) return i;
    }
    return -1;
  };
  if (n & 1) {
    odd++;
    if (k < m / 2) return 'NO';
    n--;
    k -= m / 2;
    for (let i = 0; i < m; i += 2) {
      var _res$;
      const ch = next((_res$ = res[0][i - 1]) !== null && _res$ !== void 0 ? _res$ : -1);
      res[0][i] = res[0][i + 1] = ch;
    }
  }
  if (k & 1) return 'NO';
  if (k > n * Math.floor(m / 2)) return 'NO';
  out: for (let i = 0; i < m; i += 2) {
    for (let j = odd; j < n + odd; j++) {
      if (k--) {
        var _res$j, _res$i, _res, _res2, _res3;
        const ch = next((_res$j = res[j][i - 1]) !== null && _res$j !== void 0 ? _res$j : -1, (_res$i = (_res = res[j - 1]) === null || _res === void 0 ? void 0 : _res[i]) !== null && _res$i !== void 0 ? _res$i : -1, (_res2 = (_res3 = res[j - 1]) === null || _res3 === void 0 ? void 0 : _res3[i + 1]) !== null && _res2 !== void 0 ? _res2 : 0);
        res[j][i] = res[j][i + 1] = ch;
      } else break out;
    }
  }
  for (let i = odd; i < n + odd; i++) {
    for (let j = 0; j < m; j++) {
      if (res[i][j] === undefined) {
        var _res$j2, _res4, _res$i2, _res5, _res6;
        const ch = next((_res$j2 = (_res4 = res[i - 1]) === null || _res4 === void 0 ? void 0 : _res4[j]) !== null && _res$j2 !== void 0 ? _res$j2 : -1, (_res$i2 = res[i][j - 1]) !== null && _res$i2 !== void 0 ? _res$i2 : -1, (_res5 = (_res6 = res[i + 1]) === null || _res6 === void 0 ? void 0 : _res6[j - 1]) !== null && _res5 !== void 0 ? _res5 : -1);
        res[i][j] = res[i + 1][j] = ch;
      }
    }
  }
  return `YES\n${res.map(arr => arr.map(num => String.fromCharCode(num + 97)).join('')).join('\n')}`;
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const [n, m, k] = (await read()).split(' ').map(Number);
      res[i] = solve(n, m, k);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});