You are given a table $$$a$$$ of size $$$n \times m$$$. We will consider the table rows numbered from top to bottom from $$$1$$$ to $$$n$$$, and the columns numbered from left to right from $$$1$$$ to $$$m$$$. We will denote a cell that is in the $$$i$$$-th row and in the $$$j$$$-th column as $$$(i, j)$$$. In the cell $$$(i, j)$$$ there is written a number $$$(i - 1) \cdot m + j$$$, that is $$$a_{ij} = (i - 1) \cdot m + j$$$.A turtle initially stands in the cell $$$(1, 1)$$$ and it wants to come to the cell $$$(n, m)$$$. From the cell $$$(i, j)$$$ it can in one step go to one of the cells $$$(i + 1, j)$$$ or $$$(i, j + 1)$$$, if it exists. A path is a sequence of cells in which for every two adjacent in the sequence cells the following satisfies: the turtle can reach from the first cell to the second cell in one step. A cost of a path is the sum of numbers that are written in the cells of the path.  For example, with $$$n = 2$$$ and $$$m = 3$$$ the table will look as shown above. The turtle can take the following path: $$$(1, 1) \rightarrow (1, 2) \rightarrow (1, 3) \rightarrow (2, 3)$$$. The cost of such way is equal to $$$a_{11} + a_{12} + a_{13} + a_{23} = 12$$$. On the other hand, the paths $$$(1, 1) \rightarrow (1, 2) \rightarrow (2, 2) \rightarrow (2, 1)$$$ and $$$(1, 1) \rightarrow (1, 3)$$$ are incorrect, because in the first path the turtle can't make a step $$$(2, 2) \rightarrow (2, 1)$$$, and in the second path it can't make a step $$$(1, 1) \rightarrow (1, 3)$$$.You are asked to tell the turtle a minimal possible cost of a path from the cell $$$(1, 1)$$$ to the cell $$$(n, m)$$$. Please note that the cells $$$(1, 1)$$$ and $$$(n, m)$$$ are a part of the way.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. The description of test cases follows. A single line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 10^4$$$) — the number of rows and columns of the table $$$a$$$ respectively.

For each test case output a single integer — a minimal possible cost of a path from the cell $$$(1, 1)$$$ to the cell $$$(n, m)$$$.

NoteIn the first test case the only possible path consists of a single cell $$$(1, 1)$$$.The path with the minimal cost in the second test case is shown in the statement.In the fourth and the fifth test cases there is only one path from $$$(1, 1)$$$ to $$$(n, m)$$$. Both paths visit every cell in the table.

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

let lineCounter = 0
// multi line input
readline.on('line', (line) => {
  if (lineCounter > 0) {
    let [n, m] = line.split(' ').map(Number)
    console.log(optimalPath(n, m))
  }
  lineCounter++
})

let optimalPath = (n, m) => {
  let minimalCost = (m * (m - 1)) / 2

  minimalCost += (m * (n * (n + 1))) / 2

  return minimalCost
}

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];
    var n = 0, m = 0;
    for(i = 1; i <= t; i++){
        var a = lines[i].split(' ').map(Number);
        n = a[0], m = a[1];
        var ans = m * (m - 1) / 2 + m * n * (n + 1) / 2;
        console.log(ans);
    }
});

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var M = nextInt();
		var output = M * (M + 1) / 2;
		output += ((N * (N + 1) / 2)) * M;
		output -= M;
		myout(output);
	}
}

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

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

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

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

function main() {
    var t = parseInt(readline());

    for (let i = 0; i < t; i++) {
        var x = readline().split(' ');
        var n = parseInt(x[0]);
        var m = parseInt(x[1]);

        var sum = 0;
        sum += (m*(m+1))/2;
        sum += m*(n*(n+1))/2;
        sum -= m;

        console.log(sum);

    }
}

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

const solve = () => {
  const gcd = (a, b) => (a % b === 0 ? b : gcd(b, a % b));
  let t = parseInt(readline());
  while (t--) {
    let [n,m] = readline().trim().split(" ").map(cur=>parseInt(cur));
    let cnt = Math.floor((m * (m + 1))/2);
    for(let i=1;i<n;i++) cnt+=((i+1)*m);
    console.log(cnt);
  }
};
solve();

function run(m,n) {
	let c = n;
	let sum = 0;
	for (let i = 1; i < n; i++) {
		sum+=i;
	}
	while(m--){

		sum+=n;
		n+=c;
	}
	console.log(sum)
}
function runProgram(input){
	input = input.split('\n');
	let tt = +input[0];
	let i = 1;
	while(tt--){
		let data = input[i].split(' ');
		let m = +data[0];
		let n = +data[1];
		run(m,n);
		i++;
	}
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
let read="";
process.stdin.on("data",function(input){
	read+=input;
});
process.stdin.on("end",function(){
	read=read.replace(/\n$/,"");
	read=read.replace(/\n$/,'');
	runProgram(read);
});

//#region IO
'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function print(val) {
    console.log(val);
}

function readInt() {
    return parseInt(readline());
}
// Make a Snippet for the code above this and then write your logic in main();
//#endregion
function readInts() {
    return readline().split(' ').map(x=>parseInt(x));
}

function autoSum(a1,an,n) {
    return (a1+an) * n / 2;
}

function main() {
    let t = readInt();
    while(t-- > 0) {
        let [n,m] = readInts();
        print(autoSum(1,m,m) + autoSum(m,n*m,n) - m);
    }
}

/**
 * Format:
 * {type: 'number', namedVariable?: string }
 * {type: 'repeat', instructionCount: number, count: number, namedVariable?: string }
 * {type: 'array', namedVariable?: string }
 * {type: 'string', namedVariable?: string }
 */
 const readline = require('readline');

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

   let resolvePromise = null;
   const donePromise = new Promise((res, rej) => {
     resolvePromise = res;
   });

   function waitUntilDone() {
     return donePromise;
   }

   /**
    * {type: 'repeat', count: number, iteration: number, basePointer: number, pointer: number, instructionCount: number, context: array }
    */
   const stack = [];
   let pc = -1;

   function finished() {
     if (pc >= instructions.length) {
       return true;
     }
     return false;
   }

   function checkFinished() {
     // console.log(`Finish check ${pc}, ${JSON.stringify(stack)}, ${pc >= instructions.length}, ${stack.length === 1 && stack[0].pointer === stack[0].instructionCount && stack[0].count === stack[0].iteration + 1}`);
     if (pc >= instructions.length) {
       return true;
     }
     if (stack.length === 1 && stack[0].pointer === stack[0].instructionCount && stack[0].count === stack[0].iteration + 1) {
       return true;
     }
     return false;
   }

   function getNextInstructionContext() {
     if (!stack.length) {
       return {
         index: ++pc,
       }
     }
     const lastStack = stack[stack.length - 1];
     if (lastStack.pointer === lastStack.instructionCount) {
       lastStack.pointer = 0;
       lastStack.iteration = lastStack.iteration + 1;
     }
     if (lastStack.count === lastStack.iteration) {
       stack.pop();
       pc = lastStack.basePointer + lastStack.instructionCount + 1;
       return {
         index: pc,
       }
     }

     lastStack.pointer = lastStack.pointer + 1;
     return {
       index: lastStack.basePointer + lastStack.pointer,
       context: {
         namedPath: [...lastStack.context.namedPath, lastStack.iteration]
       }
     }
   }

   function pushRepeatToStack(instruction, index, context) {
     stack.push({
       type: 'repeat',
       count: typeof instruction.count === 'number' ? instruction.count : context && context.namedPath ? getIn(mappedVariables, [...context.namedPath, instruction.count]) : mappedVariables[instruction.count],
       iteration: 0,
       basePointer: index,
       pointer: 0,
       instructionCount: instruction.instructionCount,
       context: {
         namedPath: context && context.namedPath ? [...context.namedPath, instruction.namedVariable] : [instruction.namedVariable],
       }
     })
     setIn(mappedVariables, context && context.namedPath ? [...context.namedPath, instruction.namedVariable] : [instruction.namedVariable], []);
   }

   function nextInstruction() {
     if (finished()) {
       // console.warn('Calling nextInstruction after finished, something is wrong');
       return;
     }
     while (true) {
       const { index, context } = getNextInstructionContext();
       const instruction = instructions[index];

       // console.log(`Debugging: ${index}, ${JSON.stringify(context)}, ${JSON.stringify(instruction)}`);
       switch (instruction.type) {
         case 'number':
         case 'array':
         case 'string':
           return {
             ...instruction,
             namedPath: instruction.namedVariable ? context && context.namedPath ? [...context.namedPath, instruction.namedVariable] : [instruction.namedVariable] : undefined,
           }
         case 'repeat':
           pushRepeatToStack(instruction, index, context);
           break;
         default:
           // console.warn('Unclear instruction, abort');
           return;
       }
     }
   }

   function getIn(object, path) {
     for (let i = 0; i < path.length; ++i) {
       object = object[path[i]];
     }
     return object;
   }

   function setIn(object, path, value) {
     for (let i = 0; i < path.length - 1; ++i) {
       if (object[path[i]] == null) {
         object[path[i]] = {};
       }
       object = object[path[i]];
     }
     object[path[path.length - 1]] = value;
   }

   rl.on('line', line => {
     if (finished()) {
       return;
     }
     const { type, namedPath } = nextInstruction();
     switch (type) {
       case 'number':
         if (namedPath) {
           setIn(mappedVariables, namedPath, parseInt(line));
         }
         break;
       case 'string':
         if (namedPath) {
           setIn(mappedVariables, namedPath, line.trim());
         }
         break;
       case 'array':
         if (namedPath) {
           setIn(mappedVariables, namedPath, line.trim().split(' ').map(x => parseInt(x)));
         }
         break;
       default:
       // console.warn(`Value unread, received type ${type}.`);
     }

     if (checkFinished()) {
       resolvePromise(mappedVariables);
       rl.close();
     }
   });
   return {
     waitUntilDone,
   };
 }

 function solve(testCase) {
  const n = testCase.nAndM[0];
  const m = testCase.nAndM[1];
  return (m * (m - 1) / 2) + (n * (n + 1) / 2 * m);
 }

 (async function main() {
   const reader = createCLIReader([
     { type: 'number', namedVariable: 'numberOfTestCase' },
    { type: 'repeat', instructionCount: 1, count: 'numberOfTestCase', namedVariable: 'testCase' },
    { type: 'array', namedVariable: 'nAndM' },
   ]);
   const schema = await reader.waitUntilDone();

   for (let i = 0; i < schema.numberOfTestCase; ++i) {
     console.log(solve(schema.testCase[i]));
   }
 })();

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

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

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

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

function main() {
    var t = parseInt(readline());

    for (let i = 0; i < t; i++) {
        var x = readline().split(' ');
        var n = parseInt(x[0]);
        var m = parseInt(x[1]);

        var sum = 0;
        for (let j = 0; j < m; j++) {
            sum += (j+1);
        }
        for (let j = 0; j < n; j++) {
            sum += m*(j+1);
        }
        sum -= m;

        console.log(sum);

    }
}

const process = require("process");

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

let line = "";

process.stdin.on("data", (data) => {
  line += data + "\n";
});

process.stdin.on("end", () => {
  line = line.trim().split("\n");
  main();
});

function main() {
  const t = Number(line[0]);
  //   console.log(t);
  let j = 1;

  while (j < t + 1) {
    const [n, m] = line[j++].split(" ");
    solve(Number(n), Number(m));
  }
}

function solve(m, n) {
  let val = n,
    sum = (n * (n + 1)) / 2;
  val = 2 * val;

  let i = 1;

  while (i < m) {
    sum += val;
    val = val + n;
    i++;
  }

  console.log(sum);
}

'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 findKthLargest(nums, k) {
    k = nums.length - k;
    const quickSelect = (l, r) => {
        let pivot = nums[r];
        let p = l;
        for (let i = l; i < r; i++) {
            if (nums[i] <= pivot) {
                swapper(nums, p, i);
                p++;
            }
        }
        swapper(nums, p, r);

        if (p > k) return quickSelect(l, p - 1);
        else if (p < k) return quickSelect(p + 1, r);
        else return nums[p];
    };

    return quickSelect(0, nums.length - 1);
};

function swapper(array, a, b) {
    const temp = array[b];
    array[b] = array[a];
    array[a] = temp;
};

function main() {
    const t = readline() - 1;
    for (var l = 0; l <= t; l++) {
        const [n, m] = readline().split(' ').map(r => (r) - 0);
        if (m == 1) {
            const x = n * (n + 1) / 2;
            foo(String(x));
        }
        else {
            const x = m * (m + 1) / 2;
            const y = (2*m + (n-1)*m) * n/ 2;
            foo(String(x+y-m));
        }
    }
}
function foo(x) {
    process.stdout.write(x);   // without auto '\n' (newline)
    console.log();  // with auto '\n' (newline)
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
//
let standardInputString = "";
let currentLine = 0;
//
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function readline() {
  return standardInputString[currentLine++];
}
function print(data) {
  console.log(data);
}

//line to array of integers
//readline().split(' ').map(Number)
//  let iter=parseInt(readline())
//multiple integer construction->const [a,b,c]=integer array

function main() {
  let q = parseInt(readline());
  for (let i = 0; i < q; i++) {
    let nm = readline().split(" ").map(Number);
    print(Easy(nm[0], nm[1]));
  }
}
function Easy(n, m) {
  let nth = n;
  let a = m;
  let d = m;
  let sum = (nth / 2) * (2 * a + (nth - 1) * d);
  let sum2 = (m * (m + 1)) / 2;
  return sum + sum2 - m;
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

    for (let test = 0; test < N; test++) {
        const [rows, cols] = readline().split(' ').map(Number);
        let sum = 0;
        for (let m = 0; m < cols; m++) {
            sum += m + 1;
        }
        for (let n = 1; n < rows; n++) {
            sum += (n + 1) * cols;
        }

        output(sum);
    }
}

'use strict';

function solve(n, m) {
  return m * (m - 1) / 2 + m * n * (n + 1) / 2;
}

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] = (await read()).split(' ').map(Number);
      res[i] = solve(n, m);
    }
    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);
});

var q = Number(readline());
while(q--) {
   var s=readline().split(" ");
   var n=Number(s[0]);
   var m=Number(s[1]);
   var tot=0;
   for(i=1;i<=m;++i)
      tot+=i;
   for(i=2;i<=n;++i)
      tot+=(i-1)*m+m;
   print(tot);
}

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

// multi line input
readline.on('line', (line) => {
  if (line.length > 1) {
    let [n, m] = line.split(' ').map(Number)
    console.log(optimalPath(n, m))
  }
})

let optimalPath = (n, m) => {
  let minimalCost = (m * (m - 1)) / 2

  minimalCost += (m * (n * (n + 1))) / 2

  return minimalCost
}


Suppose you have a special $$$x$$$-$$$y$$$-counter. This counter can store some value as a decimal number; at first, the counter has value $$$0$$$. The counter performs the following algorithm: it prints its lowest digit and, after that, adds either $$$x$$$ or $$$y$$$ to its value. So all sequences this counter generates are starting from $$$0$$$. For example, a $$$4$$$-$$$2$$$-counter can act as follows:  it prints $$$0$$$, and adds $$$4$$$ to its value, so the current value is $$$4$$$, and the output is $$$0$$$;  it prints $$$4$$$, and adds $$$4$$$ to its value, so the current value is $$$8$$$, and the output is $$$04$$$;  it prints $$$8$$$, and adds $$$4$$$ to its value, so the current value is $$$12$$$, and the output is $$$048$$$;  it prints $$$2$$$, and adds $$$2$$$ to its value, so the current value is $$$14$$$, and the output is $$$0482$$$;  it prints $$$4$$$, and adds $$$4$$$ to its value, so the current value is $$$18$$$, and the output is $$$04824$$$. This is only one of the possible outputs; for example, the same counter could generate $$$0246802468024$$$ as the output, if we chose to add $$$2$$$ during each step.You wrote down a printed sequence from one of such $$$x$$$-$$$y$$$-counters. But the sequence was corrupted and several elements from the sequence could be erased.Now you'd like to recover data you've lost, but you don't even know the type of the counter you used. You have a decimal string $$$s$$$ — the remaining data of the sequence. For all $$$0 \le x, y < 10$$$, calculate the minimum number of digits you have to insert in the string $$$s$$$ to make it a possible output of the $$$x$$$-$$$y$$$-counter. Note that you can't change the order of digits in string $$$s$$$ or erase any of them; only insertions are allowed.

The first line contains a single string $$$s$$$ ($$$1 \le |s| \le 2 \cdot 10^6$$$, $$$s_i \in \{\text{0} - \text{9}\}$$$) — the remaining data you have. It's guaranteed that $$$s_1 = 0$$$.

Print a $$$10 \times 10$$$ matrix, where the $$$j$$$-th integer ($$$0$$$-indexed) on the $$$i$$$-th line ($$$0$$$-indexed too) is equal to the minimum number of digits you have to insert in the string $$$s$$$ to make it a possible output of the $$$i$$$-$$$j$$$-counter, or $$$-1$$$ if there is no way to do so.

NoteLet's take, for example, $$$4$$$-$$$3$$$-counter. One of the possible outcomes the counter could print is $$$0(4)8(1)4(7)0$$$ (lost elements are in the brackets).One of the possible outcomes a $$$2$$$-$$$3$$$-counter could print is $$$0(35)8(1)4(7)0$$$.The $$$6$$$-$$$8$$$-counter could print exactly the string $$$0840$$$.

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

var main = function() {"use strict";
    // TODO
    var s = rdS().split('').map(v => +v);
    var R = crAr(10).map(v => crAr(10));

    var foo = function(x, y) {
        //pr('x,y: ', x,y);
        var G = crAr(10).map(v => []);
        var P = crAr(10).map(v => crAr(10, null));

        var path = function(v1, v2) {
            //pr('v1, v2:', v1, v2)
            if (P[v1][v2] !== null) {
                return P[v1][v2];
            }
            //pr('opop')
            var res = -1;
            var Q = [v1];
            var was = crAr(10, null);
            was[v1] = 0;
            var p = 0;
            //pr('was', was)
            while (p < Q.length) {
                //prAr(Q)
                var curV = Q[p];
                var curL = was[curV];
                for (var i = 0; i < G[curV].length; ++i) {
                    var nextV = G[curV][i];
                    //pr(nextV)
                    if (nextV === v2) {
                        //pr('opop2')
                        return P[v1][v2] = curL + 1;;
                        break;
                    } else if (was[nextV] === null) {
                        //pr('opop3')
                        Q.push(nextV);
                        was[nextV] = curL + 1;
                        //prAr(Q);
                        //pr('was', was)
                    }
                }
                //pr(Q.length);

                ++p;
            }

            return P[v1][v2] = res;
        };

        for (var k = 0; k < 10; ++k) {
            G[k].push( (k+x)%10 );
            G[k].push( (k+y)%10 );
        }
        //prAr(G);

        var res = 0;
        //prAr(s)
        for (var k = 1; k < s.length; ++k) {
            var d1 = s[k-1];
            var d2 = s[k];
            //pr('d1,d2: ', d1,d2);

            var L = path(d1, d2);
            //pr('L: ', L)
            if (L === -1) {
                return -1;
            }
            res += L - 1;
        }

        return res;
    };

    //foo(0, 1);
    //return;

    for (var i = 0; i < 10; ++i) {
        for (var j = i; j < 10; ++j) {
            var res = foo(i, j);
            R[i][j] = R[j][i] = res;
        }
    }

    for (var i = 0; i < R.length; ++i) {
        prAr(R[i]);
    }
};

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

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


Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them and the store workers will solder a single garland of them. The resulting garland will have all the lamps you provided put in a line. Moreover, no pair of lamps of the same color will be adjacent to each other in this garland!For example, if you provide $$$3$$$ red, $$$3$$$ green and $$$3$$$ blue lamps, the resulting garland can look like this: "RGBRBGBGR" ("RGB" being the red, green and blue color, respectively). Note that it's ok to have lamps of the same color on the ends of the garland.However, if you provide, say, $$$1$$$ red, $$$10$$$ green and $$$2$$$ blue lamps then the store workers won't be able to build any garland of them. Any garland consisting of these lamps will have at least one pair of lamps of the same color adjacent to each other. Note that the store workers should use all the lamps you provided.So Polycarp has bought some sets of lamps and now he wants to know if the store workers can build a garland from each of them.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of sets of lamps Polycarp has bought. Each of the next $$$t$$$ lines contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^9$$$) — the number of red, green and blue lamps in the set, respectively.

Print $$$t$$$ lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.

NoteThe first two sets are desribed in the statement.The third set produces garland "RBRG", for example.

function main() {
  var testCasesNum = +readline();
  var testCases = [];
  for (var i = 0; i < testCasesNum; i++) {
    (function (i) {
      testCases[i] = readline();
      canPay(testCases[i]);
    })(i)
  }
}

function canPay(testCase) {
  var caseArr = testCase.split(' ').map(Number);
  var r = +caseArr[0];
  var g = +caseArr[1];
  var b = +caseArr[2];
  if ((r >= g && r >= b && r <= g + b + 1) ||
    (g >= r && g >= b && g <= r + b + 1) ||
    (b >= g && b >= r && b <= g + r + 1)) {
    print("Yes")
  } else {
    print("No")
  }
}

main()

'use strict';

let col = +readline();

let strings = [];
for (let i = 0; i < col; i++){
	strings[i] = readline();
	strings[i] = strings[i].split(" ").map(function(item) {
		return +item;
	});
}

function yesNo(arr) {
	let max = 0;
	for (let i = 0; i < 3; i++) {
		if (max <= arr[i]) {
			max = arr[i];
		}
	}
	let sum = arr[0] + arr[1] + arr[2];
	if (max - 1 > (sum - max)) {
		return 'No\n';
	} else {
		return 'Yes\n';
	}
}

for (let i = 0; i < col; i++) {
	let res = yesNo(strings[i]);
	print(res);
}

var t = parseInt(readline(), 10),
    inp = [];

for(var i=1; i<=t; i++) {
    inp = readline().split(' ').map(el => parseInt(el, 10));
    r = inp[0];
    g = inp[1];
    b = inp[2];

    if(r>=g && r>=b) {
        if(g+b >= r-1) print('YES');
        else print('NO');
    } else if(g>=r && g>=b) {
        if(r+b >= g-1) print('YES');
        else print('NO');
    } else if(b>=r && b>=g) {
        if(r+g >= b-1) print('YES');
        else print('NO');
    }
}

let input = "";
const { EOL } = require("os");
process.stdin.on("data", i => (input += i));

process.stdin.on("end", func);

async function func() {
  const [t, ...queries] = input.split(EOL);
  for (let i = 0; i < t; i++) {
    const [r, g, b] = queries.shift().split(" ").map(a => parseInt(a));
    if (r + g + 1 < b || r + b + 1 < g || g + b + 1 < r) {
      console.log('No')
    } else {
      console.log('Yes')
    }
  }
}

module.exports = func;

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

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

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

  const t = parseInt(arr.shift())

  for(let i = 0; i < t; i++) {
    const r = arr[i].split(' ').map(a => parseInt(a))
    sort(r)
    if(r[2] - r[1] - r[0] > 1) wr('No')
    else wr('Yes')
  }
})

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

function max(...x) {
  return Math.max(...x)
}

function min(...x) {
  return Math.min(...x)
}

function mod(a, m) {
  let x = a % m
  if(x >= 0 )  return x
  else return m + x
}

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

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  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';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var tmp = nextIntArray();
    tmp.sort(function(a,b){
    	return b - a;
    });
    var max = tmp[0];
    var mins = tmp[1] + tmp[2];

    if(max - mins < 2){
      output[i] = "Yes";
    }else{
      output[i] = "No";
    }
  }
  myout(myconv(output, 9));
}

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

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

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => a - b);
  const r = arr[2] - arr[1] - arr[0];

  if (r > 1) {
    console.log('NO');
  }
  else {
    console.log('YES');
  }

  c++;
});

const readline = require('readline')

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

rl.on("line", main)
let i = 0;
let n = 0;
function main(input){

	if(i == 0){
		n = 3
		i++
		return
	}
	let inputarr = input.split(' ')

	let r = parseInt(inputarr[0])
	let g = parseInt(inputarr[1])
	let b = parseInt(inputarr[2])

	let arr = [r, g, b]

	arr.sort(function(a,b) {
		return a-b

	})
	if(arr[1]+arr[0] < arr[2] - 1){

		console.log("No")
	}
	else
	{
		console.log("Yes")
	}

}

let finalInput = '';

process.stdin.setEncoding('utf-8').on('data', input => {
    finalInput += input;
});

process.stdin.setEncoding('utf-8').on('end', () => {
    let lines = finalInput.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0);
    lines.forEach(line => {
        let values = line.split(' ').map(Number).sort((a, b) => a - b);
        let result = values[2] - values[0] - values[1]  <= 1;
        console.log(result ? 'Yes' : 'No');
    });
});

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});
txt.shift();
for (let i = 0; i < txt.length; i++) {
    doit(txt[i].split(" ").filter(data=>data.length>0).map(data=>data*1));
}

function doit(tab) {
    let max=tab.indexOf(Math.max(...tab));
    let score=0;
    tab.forEach((data,index)=>{
        if(index!=max)score+=data;
    });
    if(score>=tab[max]-1){
        console.log("YES");
    }else{
        console.log("NO");

    }
}

"use strict";

let col = +readline();

let strings = [];
for (let i = 0; i < col; i++){
	strings[i] = readline();
	strings[i] = strings[i].split(" ").map(function(item) {
		return +item;
	});
}

function yesNo(arr) {
	let max = 0;
	for (let i = 0; i < 3; i++) {
		if (max <= arr[i]) {
			max = arr[i];
		}
	}
	let sum = arr[0] + arr[1] + arr[2];
	if ((sum - max) < max) {
		return 'No\n';
	} else {
		return 'Yes\n';
	}
}

for (let i = 0; i < col; i++) {
	let res = yesNo(strings[i]);
	print(res);
}

'use strict';

let col = +readline();

let strings = [];
for (let i = 0; i < col; i++){
	strings[i] = readline();
	strings[i] = strings[i].split(" ").map(function(item) {
		return +item;
	});
}

function yesNo(arr) {
	let max = 0;
	for (let i = 0; i < 3; i++) {
		if (max <= arr[i]) {
			max = arr[i];
		}
	}
	let sum = arr[0] + arr[1] + arr[2];
	if ((sum - max) <= max - 1) {
		return 'No\n';
	} else {
		return 'Yes\n';
	}
}

for (let i = 0; i < col; i++) {
	let res = yesNo(strings[i]);
	print(res);
}

"use strict";

var col = +readline();

var strings = [];
for (var i = 0; i < col; i++){
	strings[i] = readline();
	strings[i] = strings[i].split(" ").map(function(item) {
		return +item;
	});
}

function yesNo(arr) {
	let max = 0;
	for (var i = 0; i < 3; i++) {
		if (max < arr[i]) {
			max = arr[i];
		}
	}
	var sum = arr[0] + arr[1] + arr[2];
	if ((sum - max) < max) {
		return 'No';
	} else if ((sum - max) >= max) {
		return 'Yes';
	}
}

for (var i = 0; i < col; i++) {
	print(yesNo(strings[i]));
}

"use strict";

var col = +readline();

var strings = [];
for (var i = 0; i < col; i++){
	strings[i] = readline();
	strings[i] = strings[i].split(" ").map(function(item) {
		return +item;
	});
}

function yesNo(arr) {
	let max = 0;
	for (var i = 0; i < 3; i++) {
		if (max < arr[i]) {
			max = arr[i];
		}
	}
	var sum = arr[0] + arr[1] + arr[2];
	if ((sum - max) < max) {
		return 'No\n';
	} else {
		return 'Yes\n';
	}
}

for (var i = 0; i < col; i++) {
	print(yesNo(strings[i]));
}

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

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

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

  const t = parseInt(arr.shift())

  for(let i = 0; i < t; i++) {
    const [r, g, b] = arr[i].split(' ').map(a => parseInt(a))
    if(r >= g && r >= b && b + g >= r) {
      wr('Yes')
    }
    else if(g >= r && g >= b && b + r >= g) {
      wr('Yes')
    }
    else if(b >= r && b >= g && g + r >= b) {
      wr('Yes')
    }
    else wr('No')
  }
})

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

function max(...x) {
  return Math.max(...x)
}

function min(...x) {
  return Math.min(...x)
}

function mod(a, m) {
  let x = a % m
  if(x >= 0 )  return x
  else return m + x
}

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

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

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

  const arr = d.split(' ').map(Number);
  const min = Math.min(...arr);
  const max = Math.max(...arr);

  if (max - min > 1) {
    console.log('NO');
  }
  else {
    console.log('YES');
  }

  c++;
});

const readline = require('readline')

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

rl.on("line", main)
let i = 0;
let n = 0;
let arr = []
function main(input){

	if(i == 0){
		n = 3
		i++
		return
	}
	arr = []
	let inputarr = input.split(' ')

	let r = inputarr[0]
	let g = inputarr[1]
	let b = inputarr[2]

	const res = Math.abs((r-g-b))

	console.log(res > 3 ? "NO" : "YES")
}

const readline = require('readline')

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

rl.on("line", main)
let i = 0;
let n = 0;
let arr = []
function main(input){

	if(i == 0){
		n = 3
		i++
		return
	}
	arr = []
	let inputarr = input.split(' ')

	let r = parseInt(inputarr[0])
	let g = parseInt(inputarr[1])
	let b = parseInt(inputarr[2])

	if(r === g){
		if(r > b){
			console.log("No")
			return
		}
	}

	if(g === b){
		if(g > r){
			console.log("No")
			return
		}
	}

	if(r === b){
		if(r > b){
			console.log("No")
			return
		}
	}

	const res = Math.abs((r-g-b))

	console.log(res > 3 ? "No" : "Yes")

}

const readline = require('readline')

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

rl.on("line", main)
let i = 0;
let n = 0;
let arr = []
function main(input){

	if(i == 0){
		n = 3
		i++
		return
	}
	arr = []
	let inputarr = input.split(' ')

	let r = inputarr[0]
	let g = inputarr[1]
	let b = inputarr[2]

	if(r === g){
		if(r > b){
			console.log("NO")
			return
		}
	}

	if(g === b){
		if(g > r){
			console.log("NO")
			return
		}
	}

	if(r === b){
		if(r > b){
			console.log("NO")
			return
		}
	}

	const res = Math.abs((r-g-b))

	console.log(res > 3 ? "NO" : "YES")

}

const readline = require('readline')

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

rl.on("line", main)
let i = 0;
let n = 0;
let arr = []
function main(input){

	if(i == 0){
		n = 3
		i++
		return
	}
	arr = []
	let inputarr = input.split(' ')

	let r = inputarr[0]
	let g = inputarr[1]
	let b = inputarr[2]

	if(r === b || r === g || g === b){
		console.log("NO")
	}

	console.log(r-b-g)
	const res = Math.abs((r-g-b))

	console.log(res > 3 ? "NO" : "YES")

}

const readline = require('readline')

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

rl.on("line", main)
let i = 0;
let n = 0;
let arr = []
function main(input){

	if(i == 0){
		n = 3
		i++
		return
	}
	arr = []
	let inputarr = input.split(' ')

	let r = inputarr[0]
	let g = inputarr[1]
	let b = inputarr[2]

	const res = Math.abs((r-g-b))

	console.log(res >= 3 ? "NO" : "YES")

}


Lee was cleaning his house for the party when he found a messy string under the carpets. Now he'd like to make it clean accurately and in a stylish way...The string $$$s$$$ he found is a binary string of length $$$n$$$ (i. e. string consists only of 0-s and 1-s).In one move he can choose two consecutive characters $$$s_i$$$ and $$$s_{i+1}$$$, and if $$$s_i$$$ is 1 and $$$s_{i + 1}$$$ is 0, he can erase exactly one of them (he can choose which one to erase but he can't erase both characters simultaneously). The string shrinks after erasing.Lee can make an arbitrary number of moves (possibly zero) and he'd like to make the string $$$s$$$ as clean as possible. He thinks for two different strings $$$x$$$ and $$$y$$$, the shorter string is cleaner, and if they are the same length, then the lexicographically smaller string is cleaner.Now you should answer $$$t$$$ test cases: for the $$$i$$$-th test case, print the cleanest possible string that Lee can get by doing some number of moves.Small reminder: if we have two strings $$$x$$$ and $$$y$$$ of the same length then $$$x$$$ is lexicographically smaller than $$$y$$$ if there is a position $$$i$$$ such that $$$x_1 = y_1$$$, $$$x_2 = y_2$$$,..., $$$x_{i - 1} = y_{i - 1}$$$ and $$$x_i < y_i$$$.

The first line contains the integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.  Next $$$2t$$$ lines contain test cases — one per two lines. The first line of each test case contains the integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the string $$$s$$$. The second line contains the binary string $$$s$$$. The string $$$s$$$ is a string of length $$$n$$$ which consists only of zeroes and ones. It's guaranteed that sum of $$$n$$$ over test cases doesn't exceed $$$10^5$$$.

Print $$$t$$$ answers — one per test case. The answer to the $$$i$$$-th test case is the cleanest string Lee can get after doing some number of moves (possibly zero).

NoteIn the first test case, Lee can't perform any moves.In the second test case, Lee should erase $$$s_2$$$.In the third test case, Lee can make moves, for example, in the following order: 11001101 $$$\rightarrow$$$ 1100101 $$$\rightarrow$$$ 110101 $$$\rightarrow$$$ 10101 $$$\rightarrow$$$ 1101 $$$\rightarrow$$$ 101 $$$\rightarrow$$$ 01.

function solve() {
   var T = Number(read());
   for (var t = 0; t < T; t++) {
      var n = Number(read());
      var s = read();
      var firstOne = s.indexOf('1');
      var lastZero = s.lastIndexOf('0');
      if (firstOne < lastZero && firstOne !== -1) {
         s = s.substr(0, firstOne) + s.substr(lastZero);
      }
      write(s);
   }
}

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

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         solve();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', solve);
   }
} else {
   solve();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStd) => {
  inputString += inputStd;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    let _ = +readLine();
    let str = readLine();
    let countZero = 0;
    let countOne = 0;
    for (let i = 0; i < str.length; i++) {
      if (str[i] === "0") {
        countZero++;
      } else {
        break;
      }
    }
    for (let i = str.length - 1; i >= 0; i--) {
      if (str[i] === "1") {
        countOne++;
      } else {
        break;
      }
    }
    if (countOne + countZero === str.length) {
      console.log(str);
    } else {
      console.log(`${"0".repeat(countZero)}0${"1".repeat(countOne)}`);
    }
  }
}

var data = '';
process.stdin.setEncoding('utf8');

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

process.stdin.on('end', () =>
{
    var x = data.split(/\s+/);
    var i = 1;

    for (var cas = 0; cas < x[0]; cas++, i += 2)
    {
        var n = x[i];
        var res = '';
        var str = x[i + 1];
        var len = str.length;
        var left = 0, right = len - 1;
        for (; left < len && str[left] == '0'; left++);
        for (; right >= 0 && str[right] == '1'; right--);
        for (var j = 0; j < left; j++) res += '0';
        if (left < right) res += '0';
        for (var j = right + 1; j < len; j++) res += '1';
        console.log(res);
    }
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input = '';
process.stdin.on('data', (line) => {
    input += line;
});
process.stdin.on('end', () => {
    const lines = input.split('\n');
    let tests = parseInt(lines.shift(), 10);
    while (tests--) {
        lines.shift();
        const s = lines.shift();
        let zeroCount = 0;
        let ans = [...s]
            .reverse()
            .reduce((acc, char) => {
            if (char === '0') {
                zeroCount++;
            }
            else if (zeroCount) {
                zeroCount = 1;
            }
            else {
                acc += char;
            }
            return acc;
        }, '');
        ans += '0'.repeat(zeroCount);
        console.log([...ans].reverse().join(''));
    }
});
// input helper
function lineToNumArray(line) {
    return line.split(' ').map(element => parseInt(element, 10));
}

const processData = (lines) => {
  let acc = 0
  const n = +lines[acc]
  acc++
  for (let i=0; i<n; i++) {
    const a = +lines[acc]
    acc++
    const l = lines[acc]
    acc++

    let left = 0
    let right = l.length
    while(l[left] === '0') {
      left++
    }
    while(l[right-1] === '1') {
      right--
    }

    // console.log(l)
    // console.log(left, right)

    if (left >= right) {
      console.log(l)
    } else {
      // console.log('left', l.slice(0, left))
      // console.log('right', l.slice(right))
      console.log(l.slice(0, left) + '0' + l.slice(right))
    }

    //
    // const zeroPoint = l.indexOf('0')
    // const onePoint = l.indexOf('1')
    // const secondZeroPoint = l.indexOf('0', onePoint)
    //
    // if (zeroPoint === 0) {
    //   if (secondZeroPoint > 0) {
    //     console.log(l.slice(0, onePoint) + '0')
    //   } else {
    //     console.log(l)
    //   }
    // } else {
    //   if (zeroPoint > 0 ) {
    //     console.log('0')
    //   } else {
    //     console.log(l)
    //   }
    // }
  }
}

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

var t = parseInt(readline());

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

  var cur = 0;
  var isDesc = false;
  while(cur + 1 < n){
    if(str[cur] == '1' && str[cur + 1] == '0'){
      isDesc = true;
      break;
    }
    cur++;
  }

  if(isDesc) {
    var newstr = "";
    leadZ = 0;
    while(leadZ < n && str[leadZ] == '0')
      leadZ++;
    leadZ++;
    sufO = 0;
    while(sufO < n && str[n - 1 - sufO] == '1')
      sufO++;

    while(leadZ--)
      newstr += "0";

    while(sufO--)
      newstr += "1";

    print(newstr);
  } else {
    print(str);
  }

}

function solve() {
   var T = Number(read());
   for (var t = 0; t < T; t++) {
      read();
      var s = read();
      var firstOne = s.indexOf('1');
      var lastZero = s.lastIndexOf('0');
      if (firstOne < lastZero && firstOne !== -1) {
         s = s.substr(0, firstOne) + s.substr(lastZero);
      }
      write(s);
   }
}

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

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         solve();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', solve);
   }
} else {
   solve();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}


Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exactly k of the nodes should be exit-nodes, that means that each of them should be connected to exactly one other node of the network, while all other nodes should be connected to at least two nodes in order to increase the system stability.Arkady wants to make the system as fast as possible, so he wants to minimize the maximum distance between two exit-nodes. The distance between two nodes is the number of wires a package needs to go through between those two nodes.Help Arkady to find such a way to build the network that the distance between the two most distant exit-nodes is as small as possible.

The first line contains two integers n and k (3 ≤ n ≤ 2·105, 2 ≤ k ≤ n - 1) — the total number of nodes and the number of exit-nodes. Note that it is always possible to build at least one network with n nodes and k exit-nodes within the given constraints.

In the first line print the minimum possible distance between the two most distant exit-nodes. In each of the next n - 1 lines print two integers: the ids of the nodes connected by a wire. The description of each wire should be printed exactly once. You can print wires and wires' ends in arbitrary order. The nodes should be numbered from 1 to n. Exit-nodes can have any ids. If there are multiple answers, print any of them.

NoteIn the first example the only network is shown on the left picture.In the second example one of optimal networks is shown on the right picture.Exit-nodes are highlighted.

var s=readline().split(' ')
var n=+s[0]
var k=+s[1]
var dist=[]
dist.length=n+1
var q=[]
dist[1]=0
var res=[]
for (var i=2;i<=k+1;i++)
{
    dist[i]=1
    res.push("1 "+i)
}
for (var i=2;i<=n;i++)
{
    if (i+k<=n)
    {
        res.push(i+' '+(i+k))
        dist[i+k]=1+dist[i]
    }
    else{q.push(dist[i]);}
}
print(q[q.length-1]+q[q.length-2])
for (var i=0;i<n-1;i++)
{
    print(res[i])
}


Vasya has recently found out what a digital root of a number is and he decided to share his knowledge with you.Let's assume that S(n) is the sum of digits of number n, for example, S(4098) = 4 + 0 + 9 + 8 = 21. Then the digital root of number n equals to:   dr(n) = S(n), if S(n) < 10;  dr(n) = dr( S(n) ), if S(n) ≥ 10. For example, dr(4098)  =  dr(21)  =  3.Vasya is afraid of large numbers, so the numbers he works with are at most 101000. For all such numbers, he has proved that dr(n)  =  S( S( S( S(n) ) ) ) (n ≤ 101000).Now Vasya wants to quickly find numbers with the given digital root. The problem is, he hasn't learned how to do that and he asked you to help him. You task is, given numbers k and d, find the number consisting of exactly k digits (the leading zeroes are not allowed), with digital root equal to d, or else state that such number does not exist.

The first line contains two integers k and d (1 ≤ k ≤ 1000; 0 ≤ d ≤ 9).

In a single line print either any number that meets the requirements (without the leading zeroes) or "No solution" (without the quotes), if the corresponding number does not exist. The chosen number must consist of exactly k digits. We assume that number 0 doesn't contain any leading zeroes.

NoteFor the first test sample dr(5881)  =  dr(22)  =  4.For the second test sample dr(36172)  =  dr(19)  =  dr(10)  =  1.

print(function(k, d) {
	if (k > 1 && d === 0) return 'No solution';
	var ans = [d];
	k--;
	while (k--)
		ans.push('0');
	return ans.join('');
} .apply(0, readline().split(' ').map(Number)));

;(function () {

	print((function (k, d) {
		k = +k;
		if (d === '0' && k > 1) return 'No solution';
		for (var i = 1; i < k; i++) d += '0';
		return d;
	}).apply(this, readline().split(' ')));

}).call(this);

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

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

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

function main() {

	function solve(numDigits, digitalRoot) {
		if (digitalRoot == 0) {
			print(numDigits == 1 ? 0 : "No solution");
			return;
		}
		var digits = [digitalRoot];
		for (var digitIndex = 1; digitIndex < numDigits; ++digitIndex) {
			digits.push(0);
		}
		print(digits.join(""));
	}

	var data = tokenizeIntegers(readline());
	solve(data[0], data[1]);
}

main();

print(function(k, d) {
	if (k === 0 && d > 1) return 'No solution';
	var ans = [d];
	k--;
	while (k--)
		ans.push('0');
	return ans.join('');
} .apply(0, readline().split(' ').map(Number)));

;(function () {

	print((function (k, d) {
		for (var i = 1, k = +k; i < k; i++) d += '0';
		return d;
	}).apply(this, readline().split(' ')));

}).call(this);

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

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

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

function main() {

	function solve(numDigits, digitalRoot) {
		if (digitalRoot == 0) {
			print(numDigits == 1 ? 0 : "Impossible");
			return;
		}
		var digits = [digitalRoot];
		for (var digitIndex = 1; digitIndex < numDigits; ++digitIndex) {
			digits.push(0);
		}
		print(digits.join(""));
	}

	var data = tokenizeIntegers(readline());
	solve(data[0], data[1]);
}

main();


Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round.You are a new applicant for his company. Boboniu will test you with the following chess question:Consider a $$$n\times m$$$ grid (rows are numbered from $$$1$$$ to $$$n$$$, and columns are numbered from $$$1$$$ to $$$m$$$). You have a chess piece, and it stands at some cell $$$(S_x,S_y)$$$ which is not on the border (i.e. $$$2 \le S_x \le n-1$$$ and $$$2 \le S_y \le m-1$$$).From the cell $$$(x,y)$$$, you can move your chess piece to $$$(x,y')$$$ ($$$1\le y'\le m, y' \neq y$$$) or $$$(x',y)$$$ ($$$1\le x'\le n, x'\neq x$$$). In other words, the chess piece moves as a rook. From the cell, you can move to any cell on the same row or column.Your goal is to visit each cell exactly once. Can you find a solution?Note that cells on the path between two adjacent cells in your route are not counted as visited, and it is not required to return to the starting point.

The only line of the input contains four integers $$$n$$$, $$$m$$$, $$$S_x$$$ and $$$S_y$$$ ($$$3\le n,m\le 100$$$, $$$2 \le S_x \le n-1$$$, $$$2 \le S_y \le m-1$$$) — the number of rows, the number of columns, and the initial position of your chess piece, respectively.

You should print $$$n\cdot m$$$ lines. The $$$i$$$-th line should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \leq x_i \leq n$$$, $$$1 \leq y_i \leq m$$$), denoting the $$$i$$$-th cell that you visited. You should print exactly $$$nm$$$ pairs $$$(x_i, y_i)$$$, they should cover all possible pairs $$$(x_i, y_i)$$$, such that $$$1 \leq x_i \leq n$$$, $$$1 \leq y_i \leq m$$$. We can show that under these constraints there always exists a solution. If there are multiple answers, print any.

'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() {
    const line = readline();
    var cases = line.split(" ");
    var n = parseInt(cases[0]);
    var m = parseInt(cases[1]);
    var x = parseInt(cases[2]);
    var y = parseInt(cases[3]);
    pathPrint(n,m,x,y);
}

function pathPrint(n,m,x,y){
  var currX = x;
  var currY = y;

  var reachedX = -1;
  var reachedY = -1;

    for(var i = currY; i >=1; i--){
        console.log(currX + " "+i);
    }
    for(var j = currY+1;j <=m;j++){
        console.log(currX+ " "+j);
    }

    reachedX = currX;
    reachedY = m;

    var rowAbove = currX-1;
    var rowBelow = currX+1;

    while(rowAbove>=1 && rowBelow<=n){
        reachedX = rowAbove;
        reachedY = m;
        for(var col1 = reachedY ; col1>=1;col1--){
            console.log(reachedX+ " "+col1);
        }
        reachedX = rowBelow;
        reachedY = 1;
        for(var col = 1 ; col<=m;col++){
            console.log(reachedX+ " "+col);
        }
        rowAbove--;
        rowBelow++;
    }

    if(rowBelow <=n){
        reachedX = rowBelow;
        reachedY = m;
        while(rowBelow <=n){
            reachedX = rowBelow;
            if(reachedY == m){
                for(var col2 = m ; col2>=1;col2--){
                    console.log(reachedX+ " "+col2);
                }
                reachedY = 1;
            }else{
                for(var col3 = 1 ; col3<=m;col3++){
                    console.log(reachedX+ " "+col3);
                }
                reachedY = m;
            }
            rowBelow++;
        }
    }

    if(rowAbove >=1){
        reachedX = rowAbove;
        reachedY = m;
        while(rowAbove >=1){
            reachedX = rowAbove;
            if(reachedY == m){
                for(var col4 = m ; col4>=1;col4--){
                    console.log(reachedX+ " "+col4);
                }
                reachedY = 1;
            }else{
                for(var col5 = 1 ; col5<=m;col5++){
                    console.log(reachedX+ " "+col5);
                }
                reachedY = m;
            }
            rowAbove--;
        }
    }
}

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

  for (let row = 0; row < rowLen; row++) {
    for (let col = 0; col < colLen; col++) {
      console.log(`${x} ${y}`);
      y++;
      if (y > colLen) y = 1;
    }
    y--;
    x++;
    if (y === 0) y = colLen;
    if (x > rowLen) x = 1;
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let [rowLen, colLen, x, y] = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  const visited = {};

  for (let i = y; i <= colLen; i++) {
    console.log(`${x} ${i}`);
  }
  for (let i = y - 1; i > 0; i--) {
    console.log(`${x} ${i}`);
  }

  let reverse = false;

  for (let row = 1; row <= rowLen; row++) {
    for (let col = 1; col <= colLen; col++) {
      if (x === row) {
        reverse = true;
        continue;
      }
      if (!reverse) {
        if (row % 2 !== 0) {
          console.log(`${row} ${col}`);
        } else {
          console.log(`${row} ${colLen + 1 - col}`);
        }
      } else {
        if (row % 2 === 0) {
          console.log(`${row} ${col}`);
        } else {
          console.log(`${row} ${colLen + 1 - col}`);
        }
      }
    }
  }
}

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

let stdinInput = '';

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

process.stdin.on('end', () => {
  main(stdinInput);
});

function main(data) {
// 	data = data.split('\n');
// 	const testCases = data[0] * 1;
// 	let i = 1;
// 	while (i <= testCases) {
    let num = data.trim().split(' ').map(Number);
    let n = num[0];
    let m = num[1];
    let x = num[2];
    let y = num[3];
    console.log(x+' '+y);
    for (let c = m; c >= 1; c -= 1) {
      if (c !== y) console.log(x+' '+c);
    }
    let check = false;
    for (let i = 0; i < n; i++) {
        if (i+1 === x) {check=true; continue;}
      if (check) {
          if (i % 2 !== 0) {
          for (let j = 0; j < m; j++) console.log((i+1)+' '+(j+1));

        // If current row is odd, print from
        // right to left
        } else {
            for (let j = m - 1; j >= 0; j--)
                console.log((i+1)+' '+(j+1));
        }
      }
        // If current row is even, print from
        // left to right
      else {
        if (i % 2 == 0) {
          for (let j = 0; j < m; j++) console.log((i+1)+' '+(j+1));

        // If current row is odd, print from
        // right to left
        } else {
            for (let j = m - 1; j >= 0; j--)
                console.log((i+1)+' '+(j+1));
        }
      }

    // i += 1;
	}
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
  const [n, m, sx, sy] = readLine().split(/\s/).map(Number)
  const visited = Array(n).fill().map(() => [])
  console.log(sx, sy)
  visited[sx - 1][sy - 1] = true
  console.log(1, sy)
  visited[0][sy - 1] = true
  console.log(1, 1)
  visited[0][0] = true
  for (let r = 0; r < n; r++) {
    for (let _c = 0; _c < m; _c++) {
      const c = r % 2 === 0 ? _c : m - 1 - _c
      if (!visited[r][c]) {
        console.log(r + 1, c + 1)
        visited[r][c] = true
      }
    }
  }
}

const main = () => {
  const input = readline()
    .split(" ")
    .map((i) => Number(i));

  const N = input[0];
  const M = input[1];

  const pos = {
    x: input[2],
    y: input[3],
  };

  for (var i = pos.x; i <= N; i++) {
    print(i, pos.y);
  }

  for (var i = pos.x - 1; i >= 1; i--) {
    print(i, pos.y);
  }

  pos.x = 1;

  for (var i = 1; i < pos.y; i++) {
    if (pos.x === 1) {
      for (var j = 1; j <= N; j++) {
        print(j, i);
      }

      pos.x = N;
    } else {
      for (var j = N; j >= 1; j--) {
        print(j, i);
      }

      pos.x = 1;
    }
  }

  for (var i = pos.y + 1; i <= M; i++) {
    if (pos.x === 1) {
      for (var j = 1; j <= N; j++) {
        print(j, i);
      }

      pos.x = N;
    } else {
      for (var j = N; j >= 1; j--) {
        print(j, i);
      }

      pos.x = 1;
    }
  }
};

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++];
}
function main() {
  let [rowLen, colLen, x, y] = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  const visited = {};

  for (let i = y; i <= colLen; i++) {
    console.log(`${x} ${i}`);
    visited[`${x}_${i}`] = true;
  }
  for (let i = y - 1; i > 0; i--) {
    console.log(`${x} ${i}`);
    visited[`${x}_${i}`] = true;
  }

  for (let row = 1; row <= rowLen; row++) {
    for (let col = 1; col <= colLen; col++) {
      if (row % 2 !== 0) {
        !visited[`${row}_${col}`] && console.log(`${row} ${col}`);
      } else {
        !visited[`${row}_${colLen + 1 - col}`] && console.log(`${row} ${colLen + 1 - col}`);
      }
    }
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const [x, y, a, b] = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  const visited = {};
  const arr = [...Array(x).fill(0)].map((_) => Array(y).fill(0));
  arr[a - 1][b - 1] = 1;
  traverse(a - 1, b - 1);

  function traverse(a, b) {
    if (a < 0 || a >= x || b < 0 || b >= y || visited[`${a}${b}`]) return;

    console.log(`${a + 1} ${b + 1}`);

    visited[`${a}${b}`] = 1;

    traverse(a, b + 1);
    traverse(a - 1, b);
    traverse(a, b - 1);
    traverse(a + 1, b);
  }
}

const main = () => {
  const input = readline()
    .split(" ")
    .map((i) => Number(i));

  const N = input[0];
  const M = input[1];

  const pos = {
    x: input[2],
    y: input[3],
  };

  for (var i = pos.x; i <= N; i++) {
    print(i, pos.y);
  }

  for (var i = pos.x - 1; i >= 1; i--) {
    print(i, pos.y);
  }

  pos.x = 1;

  for (var i = 1; i < pos.y; i++) {
    if (pos.x === 1) {
      for (var j = 1; j <= N; j++) {
        print(j, i);
      }
      pos.x = N;
    } else {
      for (var j = N; j >= 1; j--) {
        print(i, j);
      }

      pos.x = 1;
    }
  }

  for (var i = pos.y + 1; i <= M; i++) {
    if (pos.x === 1) {
      for (var j = 1; j <= N; j++) {
        print(j, i);
      }
      pos.x = N;
    } else {
      for (var j = N; j >= 1; j--) {
        print(i, j);
      }

      pos.x = 1;
    }
  }
};

main();


You are given a positive integer $$$n$$$. Your task is to find any three integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$0 \le a, b, c \le 10^9$$$) for which $$$(a\oplus b)+(b\oplus c)+(a\oplus c)=n$$$, or determine that there are no such integers.Here $$$a \oplus b$$$ denotes the bitwise XOR of $$$a$$$ and $$$b$$$. For example, $$$2 \oplus 4 = 6$$$ and $$$3 \oplus 1=2$$$.

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The following lines contain the descriptions of the test cases. The only line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^9$$$).

For each test case, print any three integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$0 \le a, b, c \le 10^9$$$) for which $$$(a\oplus b)+(b\oplus c)+(a\oplus c)=n$$$. If no such integers exist, print $$$-1$$$.

NoteIn the first test case, $$$a=3$$$, $$$b=3$$$, $$$c=1$$$, so $$$(3 \oplus 3)+(3 \oplus 1) + (3 \oplus 1)=0+2+2=4$$$.In the second test case, there are no solutions.In the third test case, $$$(2 \oplus 4)+(4 \oplus 6) + (2 \oplus 6)=6+2+4=12$$$.

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var value = parseInt(readline());
    var result = ""
    if (value % 2 === 0)
    {
        result = `${value/2} 0 0`;
    }
    else result = "-1"
    print(result)
}

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

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

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

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

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

function main() {
    var tests = parseInt(readline());
    for (let t = 0;t < tests; ++t) {
        var x = parseInt(readline());
        if (x%2 === 0) {
            console.log(x/2,x/2,0);
        } else {
            console.log(-1);
        }

    }
}

'use strict';

function solve(n) {
  if (n & 1) return -1;
  return `0 ${n / 2} ${n / 2}`;
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      res[i] = solve(n);
    }
    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);
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

    for (let test = 0; test < N; test++) {
        const n = Number(readline());

        let carry = (a, b, c) => {
            return [
                '1' + a,
                '1' + b,
                '0' + c
            ];
        };

        let dontCarry = (a, b, c) => {
            return [
                '0' + a,
                '0' + b,
                '0' + c
            ];
        }

        const bits = n.toString(2).split('').reverse().join('');
        let a = '';
        let b = '';
        let c = '';

        if (bits[0] === '1') {
            output(-1);
            continue;
        }

        for (let bit = 1; bit < bits.length; bit++) {
            if (bits[bit] === '1') {
                [a, b, c] = carry(a, b, c);
            } else {
                [a, b, c] = dontCarry(a, b, c);
            }
        }

        a = parseInt(a, 2);
        b = parseInt(b, 2);
        c = parseInt(c, 2);

        output(`${a} ${b} ${c}`);
    }
}

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

/***
Codeforces Round #804 (Div. 2)
2022-07-04

A. The Third Three Number Problem
***/

function main() {
  const t = parseInt(readline());

  for (let i = 0; i < t; i++) {
    const n = parseInt(readline());

    if (n % 2 == 0) {
      console.log(`${0} ${n / 2} ${(n, n / 2)}`);
    } else {
      console.log("-1");
    }
  }
}

function formula(a, b, c) {
  return (a ^ b) + (b ^ c) + (a ^ c);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var arr = "";
process.stdin.on("data", function (chunk) {
  arr += chunk;
});

process.stdin.on("end", function () {
  arr = arr.split("\n");
  const testcases = parseInt(arr.shift());
  for (let t = 0; t < testcases; t++) {
    const n = parseInt(arr[t]);
    if (n % 2 === 0) {
      console.log(0, 0, n / 2);
    } else {
      console.log(-1);
    }
  }
});

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

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
	var t = lines[0];
	var n = 0;
	for(i = 1; i <= t; i++){
        var k = lines[i].split(' ').map(Number);
        var a = k[0], b = k[1], c = k[2];
        console.log(a + b + c, b + c, c);
    }
});


While working at DTL, Ela is very aware of her physical and mental health. She started to practice various sports, such as Archery, Yoga, and Football.Since she started engaging in sports activities, Ela switches to trying a new sport on days she considers being "Luxury" days. She counts the days since she started these activities, in which the day she starts is numbered as day $$$1$$$. A "Luxury" day is the day in which the number of this day is a luxurious number. An integer $$$x$$$ is called a luxurious number if it is divisible by $$${\lfloor \sqrt{x} \rfloor}$$$.Here $$$\lfloor r \rfloor$$$ denotes the "floor" of a real number $$$r$$$. In other words, it's the largest integer not greater than $$$r$$$.For example: $$$8$$$, $$$56$$$, $$$100$$$ are luxurious numbers, since $$$8$$$ is divisible by $$$\lfloor \sqrt{8} \rfloor = \lfloor 2.8284 \rfloor = 2$$$, $$$56$$$ is divisible $$$\lfloor \sqrt{56} \rfloor = \lfloor 7.4833 \rfloor = 7$$$, and $$$100$$$ is divisible by $$$\lfloor \sqrt{100} \rfloor = \lfloor 10 \rfloor = 10$$$, respectively. On the other hand $$$5$$$, $$$40$$$ are not, since $$$5$$$ are not divisible by $$$\lfloor \sqrt{5} \rfloor = \lfloor 2.2361 \rfloor = 2$$$, and $$$40$$$ are not divisible by $$$\lfloor \sqrt{40} \rfloor = \lfloor 6.3246 \rfloor = 6$$$.Being a friend of Ela, you want to engage in these fitness activities with her to keep her and yourself accompanied (and have fun together, of course). Between day $$$l$$$ and day $$$r$$$, you want to know how many times she changes the activities.

Each test contains multiple test cases. The first line has the number of test cases $$$t$$$ ($$$1 \le t \le 10\ 000$$$). The description of the test cases follows. The only line of each test case contains two integers $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le 10^{18}$$$) — the intervals at which you want to know how many times Ela changes her sports.

For each test case, output an integer that denotes the answer.

NoteIn the first test case, $$$5$$$ luxury numbers in range $$$[8, 19]$$$ are: $$$8, 9, 12, 15, 16$$$.

function solve() {
    var [l, r] = readArray(BigInt);
    var firstSqrt = BigInt(Math.floor(Math.sqrt(Number(l))));
    while(firstSqrt * firstSqrt < l) {
        firstSqrt = firstSqrt + 1n;
    }
    var lastSqrt = BigInt(Math.floor(Math.sqrt(Number(r))));
    while (lastSqrt * lastSqrt + 2n * lastSqrt > r) {
        lastSqrt = lastSqrt - 1n;
    }
    var prevFirstSqrt = firstSqrt - 1n;
    var afterLastSqrt = lastSqrt + 1n;
    var ans = 0n;
    if (firstSqrt <= lastSqrt) {
        ans = (lastSqrt - firstSqrt + 1n) * 3n;
    }
    [
        prevFirstSqrt * prevFirstSqrt,
        prevFirstSqrt * prevFirstSqrt + prevFirstSqrt,
        prevFirstSqrt * prevFirstSqrt + 2n * prevFirstSqrt,
        afterLastSqrt * afterLastSqrt,
        afterLastSqrt * afterLastSqrt + afterLastSqrt,
        afterLastSqrt * afterLastSqrt + 2n * afterLastSqrt
    ].filter((x, i, a) => a.indexOf(x) === i).forEach((canBeAns) => {
        if (canBeAns >= l && canBeAns <= r) {
            ans = ans + 1n;
        }
    });
    write(ans);
}

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

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

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

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
function iInpArr1() {
  return readline()
    .trim()
    .split("")
    .map((cur) => parseInt(cur));
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const sqrt = (n) => {
  let low = 1n,
    high = n,
    ans;
  while (low <= high) {
    let mid = (low + high) / 2n;
    if (mid * mid <= n) {
      ans = mid;
      low = mid + 1n;
    } else high = mid - 1n;
  }
  return ans;
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let [l, r] = BInpArr();
    let st = sqrt(l),
      end = sqrt(r);
    const helper = (val, i) => {
      let ans = 0;
      for (let j = 0; j < 3; j++, val += i) {
        if (val >= l && val <= r) ans++;
      }
      return ans;
    };
    if (end - st >= 4n) {
      let to = end - st + 1n - 2n;
      to = to * 3n;
      to += BigInt(helper(st * st, st));
      to += BigInt(helper(end * end, end));
      console.log(to + "");
    } else {
      let ans = 0;
      for (let i = st; i <= end; i++) {
        let val = i * i;
        ans += helper(val, i);
      }
      console.log(ans);
    }
  }
};
solve();

'use strict';

var fs = require('fs');

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

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

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const l = rb(),
        r = rb();
  const sqrt = n => {
    let l = 1n,
        r = n;
    while (l < r) {
      const m = (l + r + 1n) / 2n;
      if (m * m <= n) {
        l = m;
      } else {
        r = m - 1n;
      }
    }
    return l;
  };
  const calc = n => {
    const a = sqrt(n);
    let res = (a - 1n) * 3n;
    for (let i = a; i <= a + 2n; i++) {
      if (i * a > n) break;
      res++;
    }
    return res;
  };
  return calc(r) - calc(l - 1n);
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn();
    return res;
  };
  const re = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn() - 1;
    return res;
  };
  const rbs = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rb();
    return res;
  };
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  const [rn, rb, rns, re, rbs] = convertInput(r);
  try {
    let t = rn();
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

function solve() {
    var [l, r] = readArray(BigInt);
    var firstSqrt = BigInt(Math.floor(Math.sqrt(Number(l - 1n)) + 1));
    var lastSqrt = BigInt(Math.floor(Math.sqrt(Number(r + 1n))));
    var ans = 0n;
    if (lastSqrt > firstSqrt) {
        ans = (lastSqrt - firstSqrt) * 3n;
    }
    var prevFirstSqrt = firstSqrt - 1n;
    if (lastSqrt < firstSqrt) {
        prevFirstSqrt = lastSqrt - 1n;
    }
    [
        prevFirstSqrt * prevFirstSqrt,
        prevFirstSqrt * prevFirstSqrt + prevFirstSqrt,
        prevFirstSqrt * prevFirstSqrt + 2n * prevFirstSqrt,
        lastSqrt * lastSqrt,
        lastSqrt * lastSqrt + lastSqrt,
        lastSqrt * lastSqrt + 2n * lastSqrt
    ].forEach((canBeAns) => {
        if (canBeAns >= l && canBeAns <= r) {
            ans = ans + 1n;
        }
    });
    write(ans);
}

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

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

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

function solve() {
    var [l, r] = readArray(BigInt);
    var firstSqrt = BigInt(Math.floor(Math.sqrt(Number(l - 1n)) + 1));
    var lastSqrt = BigInt(Math.floor(Math.sqrt(Number(r + 1n))));
    var ans = 0n;
    if (lastSqrt < firstSqrt) {
        [
            lastSqrt * lastSqrt,
            lastSqrt * lastSqrt + lastSqrt,
            lastSqrt * lastSqrt + 2n * lastSqrt
        ].forEach((canBeAns) => {
            if (canBeAns >= l && canBeAns <= r) {
                ans = ans + 1n;
            }
        });
        write(ans);
        return;
    }
    ans = (lastSqrt - firstSqrt) * 3n;
    var prevFirstSqrt = firstSqrt - 1n;
    [
        prevFirstSqrt * prevFirstSqrt,
        prevFirstSqrt * prevFirstSqrt + prevFirstSqrt,
        prevFirstSqrt * prevFirstSqrt + 2n * prevFirstSqrt,
        lastSqrt * lastSqrt,
        lastSqrt * lastSqrt + lastSqrt,
        lastSqrt * lastSqrt + 2n * lastSqrt
    ].forEach((canBeAns) => {
        if (canBeAns >= l && canBeAns <= r) {
            ans = ans + 1n;
        }
    });
    write(ans);
}

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

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

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

function solve() {
    var [l, r] = readArray(BigInt);
    var firstSqrt = BigInt(Math.floor(Math.sqrt(Number(l - 1n)) + 1));
    var lastSqrt = BigInt(Math.floor(Math.sqrt(Number(r + 1n))));
    var ans = (lastSqrt - firstSqrt) * 3n;
    var prevFirstSqrt = firstSqrt - 1n;
    [
        prevFirstSqrt * prevFirstSqrt,
        prevFirstSqrt * prevFirstSqrt + prevFirstSqrt,
        prevFirstSqrt * prevFirstSqrt + 2n * prevFirstSqrt,
        lastSqrt * lastSqrt,
        lastSqrt * lastSqrt + lastSqrt,
        lastSqrt * lastSqrt + 2n * lastSqrt
    ].forEach((canBeAns) => {
        if (canBeAns >= l && canBeAns <= r) {
            ans = ans + 1n;
        }
    });
    write(ans);
}

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

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

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