function solve() {
    var n = readInt()
    var arr = readIntArray()

    var numSteps = 0
    var aTotal = 0
    var bTotal = 0
    var lastTotal = 0
    var turnTotal = 0
    var curPlayerIsA = true
    var aIndex = 0
    var bIndex = n
    while(aIndex < bIndex) {
        if (curPlayerIsA) {
            aTotal += arr[aIndex]
            turnTotal += arr[aIndex]
            if(turnTotal > lastTotal) {
                curPlayerIsA = false
                lastTotal = turnTotal
                turnTotal = 0
                numSteps += 1
                bIndex -= 1
            } else {
                aIndex += 1
            }
        } else {
            bTotal += arr[bIndex]
            turnTotal += arr[bIndex]
            if(turnTotal > lastTotal) {
                curPlayerIsA = true
                lastTotal = turnTotal
                turnTotal = 0
                numSteps += 1
                aIndex += 1
            } else {
                bIndex -= 1
            }
        }
    }

    if (turnTotal > 0) {
        numSteps += 1
    }

    print(`${numSteps} ${aTotal} ${bTotal}`)
}

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 readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    caseN();
  }
}

function caseN() {
  var num = +readline();
  var cds = readNumArray();
  var aInd = 0;
  var bInd = num - 1;
  var numA = 0;
  var numB = 0;
  var currV = 0;
  var steps = 0;
  while (aInd <= bInd) {
    steps++;
    var currA = 0;
    var currB = 0;
    while (currA <= currV) {
      currA += cds[aInd];
      numA += cds[aInd];
      aInd++;
      if (aInd > bInd) {
        print(steps + " " + numA + " " + numB);
        return;
      }
    }
    currV = currA;
    steps++;
    while (currB <= currV) {
      currB += cds[bInd];
      numB += cds[bInd];
      bInd--;
      if (aInd > bInd) {
        print(steps + " " + numA + " " + numB);
        return;
      }
    }
    currV = currB;
  }
}
main()

let input = require('fs')
    .readFileSync(0, 'ascii')
    .split('\n')
    .filter(line => !/^\s*$/.test(line))
    .map(l => l.split(' ').map(w => parseInt(w)));

let [t, ...tests] = input;

for (let i = 0; i < t; i++) {
    const n = tests[2*i];
    const a = tests[2*i + 1];
    let l = 0;
    let r = n - 1;
    let ra = 0;
    let rb = 0;
    let moves = 0;
    let previous_size = 0;
    while (l <= r) {
	if (l <= r) {
	    let current_size = 0;
	    while (l <= r && current_size <= previous_size) {
		current_size += a[l];
		l++;
	    }
	    ra += current_size;
	    previous_size = current_size;
	    moves++;
	}
	if (l <= r) {
	    let current_size = 0;
	    while (l <= r && current_size <= previous_size) {
		current_size += a[r];
		r--;
	    }
	    rb += current_size;
	    previous_size = current_size;
	    moves++;
	}
    }
    console.log(moves, ra, rb)
}

'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(str => str.trim());

    main();
});

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

function main() {
    const t = parseInt(readLine(), 10);
    for (let i = 0; i < t; i++) {
        const n = parseInt(readLine(), 10);
        const seq = readLine().split(' ').map(x => parseInt(x));
        let moves = 1, a = seq[0], b = 0;
        let li = 1, i = seq.length - 1, ri = i, eatenInPrevMove = a;
        let isAlicesTurn = false;
        while (i >= 1 && li - ri < 1) {
            let eatenTillNow = 0;
            if (isAlicesTurn) {
                while (li - ri < 1) {
                    eatenTillNow += seq[li];
                    li++;
                    if (eatenTillNow>eatenInPrevMove) break;
                }
                a += eatenTillNow;
            } else {
                while (li - ri < 1) {
                    eatenTillNow += seq[ri];
                    ri--;
                    if (eatenTillNow>eatenInPrevMove) break;
                }
                b += eatenTillNow;
            }
            moves++;
            isAlicesTurn = !isAlicesTurn;
            eatenInPrevMove = eatenTillNow;
        }
        console.log([moves, a, b].join(" "));

    }
    return;
}

var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
        var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray();
		var turn = true;
		var alice = 0;
		var bob = 0;
		var mae = 0;
		var now = 0;
		var move = 0;
		while(list.length > 0){
			if(turn){
				turn = false;
				while(now <= mae && list.length > 0){
					now += list.shift();
				}
				alice += now;
				mae = now;
			}else{
				turn = true;
				while(now <= mae && list.length > 0){
					now += list.pop();
				}
				bob += now;
				mae = now;
			}
			now = 0;
			move++;
		}
		output[i] = move + " " + alice + " " + bob;
	}
	myout(myconv(output,9));
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (arr) {
        let sic = 0;
        let aW = 0;
        let aL = 0;
        let bW = 0;
        let bL = 0;
        while (arr.length) {
            let sicW = 0;
            if (!(sic % 2)) {
                do {
                    sicW += arr.shift();
                } while (sicW <= bL && arr.length);
                aL = sicW;
                aW += sicW;
            } else {
                do {
                    sicW += arr.pop();
                } while (sicW <= aL && arr.length);
                bL = sicW;
                bW += sicW;
            }
            sic++;
        }
        return [sic, aW, bW].join(' ');
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let result = foo(data);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})

const processData = (lines) => {
  const num = +lines[0]
  for (let i=0; i<num; i++) {
    const n = +lines[i*2+1]
    const arr = lines[i*2 + 2].split(' ').map(x => +x)

    let aSum = 0
    let bSum = 0
    let a = 0
    let b = 0
    let start = 0
    let end = arr.length - 1
    let cur = 0
    let step = 0
    while (start <= end) {
      if (cur === 0 ) {
        a = 0
        while (start <= end && a <= b) {
          a += arr[start]
          start++
        }
        aSum += a
      } else {
        b = 0
        while (start <= end && b <= a) {
          // console.log('b', end)
          b += arr[end]
          end--
        }

        bSum += b
      }
      cur = (cur + 1) %2
      step++
    }
    console.log(step, aSum, bSum)
  }
}

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

'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 solve(n, a) {
  let steps = 0;
  let sumA = 0;
  let sumB = 0;
  let isA = true;
  let lastStep = 0;
  let i = 0;
  let j = n - 1;
  while (i <= j) {
    let curSum = 0;
    if (isA) {
      while (curSum === 0 || (curSum <= lastStep && i <= j)) {
        curSum += a[i];
        i++;
      }
      sumA += curSum;
      isA = false;
    } else {
      while (curSum === 0 || (curSum <= lastStep && i <= j)) {
        curSum += a[j];
        j--;
      }
      sumB += curSum;
      isA = true;
    }
    lastStep = curSum;
    steps++;
  }
  return [steps, sumA, sumB];
}

function main() {
  const t = parseInt(readLine());
  for (let i = 0; i < t; i++) {
    let n = parseInt(readLine());
    let a = readLine().split(' ').map((val) => parseInt(val));
    let res = solve(n, a);
    console.log(res.join(' '));
  }
  //process.stdout.write("hello: ");
}

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

var input  = []
rl.on('line', function(line){
    input.push(line);
})

rl.on("close", ContestResponse);

function ContestResponse(){
    let index = 0;
    let nCases = +input[index++];
    for (let i = 0; i < nCases; i++){
      index++;
      let arr = input[index++].split(" ").map((val) => +val);
      let prev = 0;
      let currPrev = 0;
      let alice = 0;
      let aliceIndex = 0;
      let bob = 0
      let bobIndex = arr.length - 1;
      let moves = 0;
      let turn = 0;
      let un = false;
      while (aliceIndex <= bobIndex){
        un = false;
        if (turn === 0){
          alice += arr[aliceIndex];
          if (currPrev + arr[aliceIndex] > prev){
            prev = currPrev + arr[aliceIndex];
            currPrev = 0;
            turn = 1;
            aliceIndex++;
            moves++;
          }
          else {
            currPrev += arr[aliceIndex];
            aliceIndex++;
            un = true;
          }
        }
        else{
          bob += arr[bobIndex];
          if (currPrev + arr[bobIndex] > prev){
            turn = 0;
            prev = currPrev + arr[bobIndex];
            currPrev = 0;
            bobIndex--;
            moves++;
          }
          else {
            currPrev += arr[bobIndex]
            bobIndex--;
            un = true;
          }
        }
      }
      if (un)
        moves++
      console.log(moves, alice, bob);
    }
}

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

var input  = []
rl.on('line', function(line){
    input.push(line);
})

rl.on("close", ContestResponse);

function ContestResponse(){
    let index = 0;
    let nCases = +input[index++];
    for (let i = 0; i < nCases; i++){
      index++;
      let arr = input[index++].split(" ").map((val) => +val);
      let prev = 0;
      let alicePrev = 0;
      let alice = 0;
      let aliceIndex = 0;
      let bobPrev = 0;
      let bob = 0
      let bobIndex = arr.length - 1;
      let moves = 0;
      let turn = 0;
      let un = false;
      while (aliceIndex <= bobIndex){
        if (turn === 0){
          //console.log("-----ALICE")
          if (alicePrev + arr[aliceIndex] > prev){
            //console.log(arr[aliceIndex])
            turn = 1;
            alice += arr[aliceIndex];
            alicePrev += arr[aliceIndex];
            aliceIndex++;
            moves++;
            prev = alicePrev;
            alicePrev = 0;
            un = false;
          }
          else {
            //console.log(arr[aliceIndex])
            alice += arr[aliceIndex];
            alicePrev += arr[aliceIndex];
            aliceIndex++;
            un = true;
          }
        }
        else{
          //console.log("-----BOB")
          if (bobPrev + arr[bobIndex] > prev){
            //console.log(arr[bobIndex])
            un = false;
            turn = 0;
            bob += arr[bobIndex];
            bobPrev += arr[bobIndex]
            prev = bobPrev;
            bobPrev = 0;
            bobIndex--;
            moves++;
          }
          else {
            //console.log(arr[bobIndex])
            bob += arr[bobIndex];
            bobPrev += arr[bobIndex]
            bobIndex--;
            un = true;
          }
        }
      }
      if (un)
        moves++
      console.log(moves, alice, bob);
    }
}

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

var input  = []
rl.on('line', function(line){
    input.push(line);
})

rl.on("close", ContestResponse);

function ContestResponse(){
    let index = 0;
    let nCases = +input[index++];
    for (let i = 0; i < nCases; i++){
      index++;
      let arr = input[index++].split(" ").map((val) => +val);
      let alice = 0;
      let aliceIndex = 0;
      let alicePrev = 0;
      let bob = 0;
      let bobPrev = 0;
      let bobIndex = arr.length - 1;
      let moves = 0;
      while (aliceIndex <= bobIndex){
        moves++;
        if (moves & 1){
          for (alicePrev = 0; aliceIndex <= bobIndex && alicePrev <= bobPrev; aliceIndex++)
            alicePrev += arr[aliceIndex];
            alice += alicePrev;
        }
        else {
          for (bobPrev = 0; aliceIndex <= bobIndex && bobPrev <= alicePrev; bobIndex--)
            bobPrev += arr[bobIndex];
            bob += bobPrev;
        }
      }
      console.log(moves, alice, bob);
    }
}

'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 cases = parseInt(readline(), 10);
    for (var X = 0; X < cases; X++) {
      readline();
      let candies = readline().split(" ").map(e => parseInt(e));

      let eated = [0, 0];
      let previousEating = 0;
      let turn = 0
      let count = 0;

      while (candies.length > 0) {

        let currentEating = 0;
        //console.log('start turn', turn)
        //console.log(JSON.stringify(candies));

        while (candies.length > 0 && currentEating <= previousEating) {
          currentEating += (turn == 0) ? candies.shift() : candies.pop();
          //console.log('eating', currentEating);
        }

        if (currentEating > previousEating) {
          eated[turn] += currentEating;
        } else {
          //turn = turn === 0 ? 1 : 0;
          eated[turn] += currentEating;
        }

        turn = turn === 0 ? 1 : 0;
        previousEating = currentEating;
        count++;
      }

      console.log(`${count} ${eated[0]} ${eated[1]}`)
      // console.log(`----`)

    }

}

'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(str => str.trim());

    main();
});

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

function main() {
    const t = parseInt(readLine(), 10);
    for (let i = 0; i < t; i++) {
        const n = parseInt(readLine(), 10);
        const seq = readLine().split(' ').map(x => parseInt(x));
        let moves = 1, a = seq[0], b = 0;
        let li = 1, i = seq.length - 1, ri = i, eatenInPrevMove = a;
        let isAlicesTurn = false;
        while (i > 1 && li + (i - ri) <= i) {
            let eatenTillNow = 0;
            if (isAlicesTurn) {
                while ((li + i - ri) <= i) {
                    eatenTillNow += seq[li];
                    li++;
                    if (eatenTillNow>eatenInPrevMove) break;
                }
                a += eatenTillNow;
            } else {
                while ((li + i - ri) <= i) {
                    eatenTillNow += seq[ri];
                    ri--;
                    if (eatenTillNow>eatenInPrevMove) break;
                }
                b += eatenTillNow;
            }
            moves++;
            isAlicesTurn = !isAlicesTurn;
            eatenInPrevMove = eatenTillNow;
        }
        console.log([moves, a, b].join(" "));

    }
    return;
}


print(function(a, d) {
	var n = +readline();
	var ans = [];
	for (var i = 1; i <= n; i++) {
		var x = (i * d) % (a * 4);
		if (x <= a) {
			ans.push(x + ' 0');
		} else if (x <= 2 * a) {
			ans.push(a + ' ' + (x - a))
		} else if (x <= 3 * a) {
			ans.push((3 * a - x) + ' ' + a)
		} else {
			ans.push('0 ' + (4 * a - x))
		}
	}
	return ans.join('\n');
}.apply(0, readline().split(' ').map(Number)));

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

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

function tokenizeFloats(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseFloat(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var factor = 100*100,
		data = tokenizeFloats(readline()),
		side = factor*data[0], drink = factor*data[1],
		numDrinks = parseInt(readline());
	var parts = [], pos = 0, lap = 4*side;
	for (var i = 0; i < numDrinks; ++i) {
		pos = (pos + drink) % lap;
		if (pos < side) {
			var x = pos, y = 0;
		} else if (pos < 2*side) {
			var x = side, y = pos - side;
		} else if (pos < 3*side) {
			var x = 3*side - pos, y = side;
		} else {
			var x = 0, y = lap - pos;
		}
		parts.push(x/factor);
		parts.push(' ');
		parts.push(y/factor);
		parts.push('\n');
	}
	parts.pop();
	print(parts.join(''));
}

main();


var str = readline().split(" ");
var steps = +str[1];
var nums = str[0];
var numbers = readline().split("");
var i = 0;
while (steps && i < numbers.length){
    if (numbers.length == 1){
        numbers[0] = 0;
        break;
    }
    if (i == 0 && numbers[i] != 1){
        numbers[0] = 1;
        steps--;

    } else if( i>0 && numbers[i] != 0) {
        numbers[i] = 0;
        steps--;

    }
    i++;
}
write(numbers.join(""));

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', sol);

function sol() {
  let [n, k, S] = input
    .replace('\n', ' ')
    .split(' ')
  n = Number(n)
  k = Number(k)
  S = Array.from(S)

  for (let i = 0; i < n && k > 0; ++i) {
    if (i === 0 && i !== n-1) {
      if (S[i] !== '1') {
        S[i] = '1'
        --k
      }
    } else {
      if (S[i] !== '0') {
        S[i] = '0'
        --k
      }
    }
  }

  process.stdout.write(
    S.join(''),
    'utf8',
    () => process.stdout.end()
  );
}

let lines = '';
process.stdin.on('data', c => lines += c);

const solution = () => {
	let line = lines.split('\n');
	let [n, k] = line[0].split(' ').map(v => parseInt(v,10));
	let s = line[1];
	let r = '';
	for(let i = 0; i < n; i++){
		let c = s[i];
		 if (i === 0 && n == 1 && k > 0) {
			r += 0;
			k--;
		}else if (i === 0 && c > 1 && k > 0) {
			r += 1;
			k--;
		} else if (i !== 0 && c > 0 && k > 0) {
			r += 0;
			k--;
		} else {
			r += c;
		}
	}

	console.log(r);
	process.exit(0);
}

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

'use strict'

let data = readline().split(' ');

let n = parseInt(data[0]), k = parseInt(data[1]);

let str = readline(), ans = "";

if(n == 1 && k) {
    ans += 0;
} else
if(str[0] != 1 && k) {
    -- k;
    ans += 1;
} else ans += str[0];

for (let i = 1; i < n; ++ i) {
    if(!k || str[i] == '0') {
        ans += str[i];
    } else {
        -- k;
        ans += 0;
    }
}

print(ans);

'use strict'

const fn = (k, x) => {
    if (x.length === 1 && k >= 1) return '0';
    if (k === 0) return x;
    let K = 0;
    if (x[0] !== '1') { k--; }

    while(k && K++ < x.length) {
        if (x[K] !== '0') k--;
    }
    const z = Math.min(K, x.length - 1);
    return '1' + '0'.repeat(z) + x.slice(z + 1)
}

write(fn(parseInt(readline().split(' ')[1]), readline()));

const readline = require('readline');

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

var line = 0;
var n, k;
var S;

rl.on('line', (data) => {
	++line;

	var arr = data.split(' ');

	if(line===1) {
		n = parseInt(arr[0]);
		k = parseInt(arr[1]);
	} else {
		S = arr[0];
		var array = S;
		var result = '';
//		console.log(array)

		if(k===0) {
			console.log(S);
		} else if(n===1){
			console.log(0);
		} else {
			var idx=1;
			if(array[0]!=='1'){
				--k;
			}
			result+='1';
			for(; idx<n; idx++) {
				if(k===0) {
//					console.log('K is zero for',array[idx]);
					for(var jj=idx; jj<n; jj++) {
						result+=array[jj];
//							console.log('Added',array[jj])
					}
					idx=n;
					break;
				}

				if(array[idx]==='0') {
					result+=0;
				}else {
//					console.log('Decrement for',array[idx],'K is',k-1);
					--k;
					result+=0;
				}

//				console.log(k+1,'ADDED',array[idx])
			}
			console.log(result);
		}
		line=0;
	}
});

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')
  const ax = arr.shift().split(' ')
  const s = arr.shift()
  const n = parseInt(ax[0])
  const k = parseInt(ax[1])
  let s2 = ''
  if(n == 1) {
    if(k == 1) console.log('0')
    else console.log(s)
  }
  else {
    for(let i = 0, no = 0; no < k && i < n; i++) {
      if(i == 0) s2 += 1
      else {
        s2 += 0
      }
      if(i == 0 && s[0] != 1) no ++
      else if(i !=0 && s[i] != 0) no ++
    }
    s2 += s.substr(s2.length)
    console.log(s2)

  }
})

const readline = require('readline');

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

var line = 0;
var n, k;
var S;

rl.on('line', (data) => {
	++line;

	var arr = data.split(' ');

	if(line===1) {
		n = parseInt(arr[0]);
		k = parseInt(arr[1]);
	} else {
		S = parseInt(arr[0]);
		var result = '';
		var array = Array.from(String(S), Number);

		if(k===0) {
			console.log(S);
		} else if(n===1){
			console.log(0);
		} else {
			var idx=1;
			if(array[0]!==1){
				--k;
			}
			result+='1';
			for(; idx<n; idx++) {
				if(array[idx]===0) {
					result+=0;
				}else {
					--k;
					result+=0;
					if(k===0) {
						for(var jj=idx+1; jj<n; jj++) {
							result+=array[jj];
						}
						idx=n;
					}
				}
			}
			console.log(result);
		}
		line=0;
	}
});

const readline = require('readline');

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

var line = 0;
var n, k;
var S;

rl.on('line', (data) => {
	++line;
	var arr = data.split(' ');
	if(line===1) {
		n = parseInt(arr[0]);
		k = parseInt(arr[1]);
	} else {
		S = arr[0];
		var array = S;
		var result = '';

		if(k===0) {
			console.log(S);
		} else if(n===1){
			console.log(0);
		} else {
			var idx=1;
			if(array[0]!=='1'){
				--k;
			}
			result+='1';
			for(; idx<n; idx++) {
				if(array[idx]==='0') {
					result+='0';
				}else {
					--k;
					result+=0;
				}
				if(k===0) {
					for(var jj=idx+1; jj<n; jj++) {
						result+=array[jj];
					}
					idx=n;
				}
			}
			console.log(result);
		}
		line=0;
	}
});

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')
  const ax = arr.shift().split(' ')
  const s = arr.shift()
  const n = parseInt(ax[0])
  const k = parseInt(ax[1])
  let s2 = ''
  if(n == 1) {
    console.log('0')
  }
  else {
    for(let i = 0, no = 0; no < k && i < n; i++) {
      if(i == 0) s2 += 1
      else {
        s2 += 0
      }
      if(i == 0 && s[0] != 1) no ++
      else if(s[i] != 0) no ++
    }
    s2 += s.substr(s2.length)
    console.log(s2)

  }
})

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')
  const ax = arr.shift().split(' ')
  const s = arr.shift()
  const n = parseInt(ax[0])
  const k = parseInt(ax[1])
  let s2 = ''
  for(let i = 0, no = 0; no < k; i++) {
    if(i == 0) s2 += 1
    else {
      s2 += 0
    }
    if(s[i] != 1 || s.length == 1) no ++
  }
  s2 += s.substr(s2.length)

  if(s2.length > 1) console.log(s2)
  else console.log('0')
})

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')
  const ax = arr.shift().split(' ')
  const s = arr.shift()
  const n = parseInt(ax[0])
  const k = parseInt(ax[1])
  let s2 = ''
  if(n == 1) {
    console.log('0')
  }
  else {
    for(let i = 0, no = 0; no < k && i < n; i++) {
      if(i == 0) s2 += 1
      else {
        s2 += 0
      }
      if(s[0] != 1) no ++
      else if(s[i] != 0) no ++
    }
    s2 += s.substr(s2.length)
    console.log(s2)

  }
})

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')
  const ax = arr.shift().split(' ')
  const s = arr.shift()
  const n = parseInt(ax[0])
  const k = parseInt(ax[1])
  let s2 = ''
  if(n == 1) {
    if(k == 1) console.log('0')
    else console.log(s)
  }
  else {
    for(let i = 0, no = 0; no < k && i < n; i++) {
      if(i == 0) s2 += 1
      else {
        s2 += 0
      }
      if(i == 0 && s[0] != 1) no ++
      else if(s[i] != 0) no ++
    }
    s2 += s.substr(s2.length)
    console.log(s2)

  }
})

let lines = '';
process.stdin.on('data', c => lines += c);

const solution = () => {
	let line = lines.split('\n');
	let [n, k] = line[0].split(' ').map(v => parseInt(v,10));
	let s = line[1];
	let r = '';
	for(let i = 0; i < n; i++){
		let c = s[i];
		if (i === 0 && c > 1 && k > 0) {
			r += 1;
			k--;
		} else if (i === 0 && n == 1 && k > 0) {
			r += 0;
			k--;
		} else if (i !== 0 && c > 0 && k > 0) {
			r += 0;
			k--;
		} else {
			r += c;
		}
	}

	console.log(r);
	process.exit(0);
}

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

'use strict'

let data = readline().split(' ');

let n = parseInt(data[0]), k = parseInt(data[1]);

let str = readline(), ans = "";

if(str[0] != 1 && k) {
    -- k;
    ans += 1;
} else ans += str[0];

for (let i = 1; i < n; ++ i) {
    if(!k || str[i] == '0') {
        ans += str[i];
    } else {
        -- k;
        ans += 0;
    }
}

print(ans);

'use strict'

let data = readline().split(' ');

let n = parseInt(data[0]), k = parseInt(data[1]);

let str = readline(), ans = "";

if(str[0] != 1 && k) {
    -- k;
    ans += 1;
}

for (let i = 1; i < n; ++ i) {
    if(!k || str[i] == '0') {
        ans += str[i];
    } else {
        -- k;
        ans += 0;
    }
    -- k;
}

print(ans);

'use strict'

let data = readline().split(' ');

let n = parseInt(data[0]), k = parseInt(data[1]);

let str = readline(), ans = "";

if(str[0] != 1 && k) {
    if(n == 1) {
        ans += 0;
    } else {
        -- k;
        ans += 1;
    }
} else ans += str[0];

for (let i = 1; i < n; ++ i) {
    if(!k || str[i] == '0') {
        ans += str[i];
    } else {
        -- k;
        ans += 0;
    }
}

print(ans);

'use strict'

let data = readline().split(' ');

let n = parseInt(data[0]), k = parseInt(data[1]);

let str = readline(), ans = "";

if(str[0] != 1 && k) {
    -- k;
    ans += 1;
}

for (let i = 1; i < n; ++ i) {
    if(!k || str[i] == '0') {
        ans += str[i];
    } else {
        -- k;
        ans += 0;
    }
}

print(ans);

'use strict'

let data = readline().split(' ');

let n = parseInt(data[0]), k = parseInt(data[1]);

let str = readline(), ans = "";

if(str[0] != '1' && k) {
    -- k;
    ans += 1;
}

for (let i = 1; i < n; ++ i) {
    if(!k || str[i] == '0') {
        ans += str[i];
    } else {
        -- k;
        ans += 0;
    }
    -- k;
}

print(ans);

'use strict'

let data = readline().split(' ');

let n = parseInt(data[0]), k = parseInt(data[1]);

let str = readline(), ans = "";

if(str[0] != 1 && k) {
    -- k;
    ans += 1;
} else ans += str[0];

for (let i = 1; i < n; ++ i) {
    if(!k || str[i] == '0') {
        ans += str[i];
    } else {
        -- k;
        ans += 0;
    }
    -- k;
}

print(ans);

var str = readline().split(" ");
var steps = +str[1];
var nums = str[0];
var numbers = readline().split("");
var i = 0;
while (steps){
    if (i){
        numbers[i] = 0;
        steps--;
    } else if (numbers[i] != 1){
        numbers[i] = 1;
        steps--;
    } else if (numbers.length == 1){
        numbers[0] = 0;
        steps--;
    }

    i++;
}
write(numbers.join(""));


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 t = Number(readLine())
  for (let _ = 0; _ < t; _++) {
	const [nStr, kStr] = readLine().split(/\s/)
    const n = Number(nStr)
    const k = BigInt(kStr)
    const as = readLine().split(/\s/).map(Number)
    const max = Math.max.apply(null, as)
    const as1 = as.map(a => max - a)
    if (k % 2n === 1n) {
      console.log(as1.join(' '))
      continue
    }
    const max1 = Math.max.apply(null, as1)
    console.log(as1.map(a => max1 - a).join(' '))
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const [len, time] = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    let arr = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    let max = Math.max(...arr);
    const store = [];
    for (let i = 0; i < arr.length; i++) {
      arr[i] = max - arr[i];
    }

    store.push(arr);
    max = Math.max(...arr);
    const _arr = [...arr];
    for (let i = 0; i < _arr.length; i++) {
      _arr[i] = max - _arr[i];
    }
    store.push(_arr);

    if ((time - 1) % 2 === 0) {
      console.log(store[0].join(" "));
    } else {
      console.log(store[1].join(" "));
    }
  }
}

// process.stdin.resume();
// process.stdin.setEncoding('utf8');

function readDOM(pos) {
    const inputList = document.querySelectorAll(".input");
    const input = inputList[pos];
    return input.querySelector("pre").textContent;
}

let CONFIG = {
    // getStringFunc: readDOM.bind(null, 0)
}

stdioCPPattern(CONFIG, ({ readNum, readStr, writeLine, readCharArray }) => {
    // your code goes here
    let tc_count = readNum();
    let n, kOper, dmax, arr;

    const convert = x => dmax - x;
    function maxForBigInt(...args) {
        return args.reduce((a, b) => a > b ? a : b);
    };

    while (tc_count--) {
        [n, kOper] = [Number(readNum()), readNum()];
        arr = new BigInt64Array(n).map(readNum);
        //writeLine(`[${arr}]`);

        dmax = maxForBigInt(...arr);
        arr = arr.map(convert);

        if ((kOper & 1n) === 0n) {
            dmax = maxForBigInt(...arr);
            arr = arr.map(convert);
        }
        writeLine( arr.join(" "));
    }
});

/**
 * @author flynn
 */
function stdinReadAll() {
    const fs = require("fs");
    return fs.readFileSync(0).toString();
}

function stdioCPPattern({
    getStringFunc = stdinReadAll
}, callbackfn) {
    const aStr = getStringFunc() + "\n";

    let cur = -1;
    const resultList = [];// Array(numberOfLine);
    const seperator = /\s/;
    const MINUS_CODE = -3n;

    callbackfn({
        readCharArray,
        log: console.log,
        readNum() {
            let x = 0n, sign = 1n, ch = nextDigit();
            while (ch !== MINUS_CODE && (ch < 0 || 9 < ch)) ch = nextDigit();

            if (ch === MINUS_CODE) { sign = -1n; ch = nextDigit(); }

            while (0 <= ch && ch <= 9) {
                x = x * 10n + ch;
                ch = nextDigit();
            }
            return x * sign;
        },
        writeLine(data) {
            resultList.push(`${data}`);
        },
        readStr(bufferLen = 1e6) {
            return readCharArray(bufferLen).join("");
        }
    });
    let prompt = resultList.join("\n");
    if (prompt) console.log(prompt);

    function nextDigit() {
        return BigInt(aStr.charCodeAt(++cur) - 48);
    }

    function readCharArray(bufferLen = 1e6) {
        const chArr = Array(bufferLen);
        let ch = aStr[++cur], p = 0;
        while (seperator.test(ch))
            ch = aStr[++cur];
        while (!seperator.test(ch)) {
            chArr[p++] = ch;
            ch = aStr[++cur];
        }
        return chArr.slice(0, p);
    }
}

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

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

function main() {
	let t = readLine() >> 0;
	while (t--) {
		let [n, k] = readLine().split(' ');

		n = n >> 0;
		k = BigInt(k);

		let arr = readLine()
			.split(' ')
			.map(x => x >> 0);

		k = k & 1n ? 1 : 2;
		for (let i = 0; i < k; i++) {
			let d = Math.max(...arr);
			for (let j = 0; j < n; j++) {
				arr[j] = d - arr[j];
			}
		}
		console.log(arr.join(' '));
	}
}

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 t = Number(readLine())
  for (let _ = 0; _ < t; _++) {
	const [n, k] = readLine().split(/\s/).map(Number)
    const as = readLine().split(/\s/).map(Number)
    const max = Math.max.apply(null, as)
    const as1 = as.map(a => max - a)
    if (k % 2 === 1) {
      console.log(as1.join(' '))
      continue
    }
    const max1 = Math.max.apply(null, as1)
    console.log(as1.map(a => max1 - a).join(' '))
  }
}

// process.stdin.resume();
// process.stdin.setEncoding('utf8');

function readDOM() {
    const inputList = document.querySelectorAll(".input");
    const input = inputList[2];
    return input.querySelector("pre").textContent;
}

stdioCPPattern({}, ({ readNum, readStr, writeLine, readCharArray }) => {
    // your code goes here
    let tc_count = readNum();
    let n, kOper, dmax, arr;

    const convert = x => dmax - x;

    while (tc_count--) {
        [n, kOper] = [readNum(), readNum()];
        arr = new Int32Array(n).map(readNum);

        dmax = Math.max(...arr);
        arr = arr.map(convert);

        if ((kOper & 1) === 0) {
            dmax = Math.max(...arr);
            arr = arr.map(convert);
        }
        writeLine( arr.join(" "));
    }
});

/**
 * @author flynn
 */
function stdinReadAll() {
    const fs = require("fs");
    return fs.readFileSync(0).toString();
}

function stdioCPPattern({
    getStringFunc = stdinReadAll
}, callbackfn) {
    const aStr = getStringFunc() + "\n";

    let cur = 0;
    const resultList = [];// Array(numberOfLine);
    const seperator = /\s/;
    const MINUS_CODE = -3;

    callbackfn({
        readCharArray,
        log: console.log,
        readNum() {
            let x = 0, sign = 1, ch = aStr.charCodeAt(cur) - 48;
            while (ch !== MINUS_CODE && (ch < 0 || 9 < ch)) ch = nextDigit();

            if (ch === MINUS_CODE) { sign = -1; ch = nextDigit(); }

            while (0 <= ch && ch <= 9) {
                x = x * 10 + ch;
                ch = nextDigit();
            }
            return x * sign;
        },
        writeLine(data) {
            resultList.push(`${data}`);
        },
        readStr(bufferLen = 1e6) {
            return readCharArray(bufferLen).join("");
        }
    });
    let prompt = resultList.join("\n");
    if (prompt) console.log(prompt);

    function nextDigit() {
        return aStr.charCodeAt(++cur) - 48;
    }

    function readCharArray(bufferLen = 1e6) {
        const chArr = Array(bufferLen);
        let ch = aStr[cur], p = 0;
        while (seperator.test(ch))
            ch = aStr[++cur];
        while (!seperator.test(ch)) {
            chArr[p++] = ch;
            ch = aStr[++cur];
        }
        return chArr.slice(0, p);
    }
}


var line = readline().split(' ');
var a = +line[0];
var b = +line[1];
var n = a+b;
var j = 0;
var firstDay = [];
var secondDay = [];
while (n - j -1 >= 0) {
    n -= ++j;
}
while ((j > 0) && (a+b > 0)) {
    if (a >= b) {
        a -= j--;
        firstDay.push(j+1);
    } else {
         b -= j--;
         secondDay.push(j+1);
    }
}
write(firstDay.length+'\n'+firstDay.reverse().join(' ')+'\n'+secondDay.length+'\n'+secondDay.reverse().join(' '));

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

  let standardInputString= '';
  let currentLine = 0;

  function readLine(){
    return standardInputString[currentLine++];
  }
  process.stdin.on('data', rawData =>{
    standardInputString += rawData;
  });
  process.stdin.on('end', _ =>{
    standardInputString= standardInputString.trim().split('\n').map(line =>{
      return line.trim();
    });

    main();
  })

  function main(){

    let [a,b] = readLine().split(' ').map(Number);
    // let line = readLine().split(' ').map(Number);

      let hardestDay = a>=b ? a : b;
      let easiestDay = a<=b ? a : b;
      let sum = 0;

      let easierSum = 0;

      let hardDayArr = [];
      let easiestDayArr = [];

      let imposterNumber = 0;
      let didOnce = 1;

      let smallestStart = 1;

        for(let j = 1; j<=hardestDay; ++j){

          if(sum >= hardestDay){
           imposterNumber = sum - hardestDay;
           if(imposterNumber !== 0){
            hardDayArr.splice(imposterNumber-1,1);
           }
           smallestStart = j;
           break;
          }
          else{
            sum += j;
            hardDayArr.push(j);
          }
        }
        if(imposterNumber !== 0){
          easierSum = imposterNumber
          easiestDayArr.push(easierSum);
        }
        for(smallestStart; smallestStart<=easiestDay; ++smallestStart){

          easierSum += smallestStart;
          if(easierSum <= easiestDay){
            easiestDayArr.push(smallestStart);
          }
          else{
            break;
          }
        }
        let pera = hardDayArr.length !== 0 ? hardDayArr.reduce((a,b) => a +b) : 0;
        if( pera!== hardestDay){
          hardDayArr.splice((pera - hardestDay) - 1, 1);
        };
        if(easiestDay === 0){
          easiestDayArr = [];
        }
        else if( hardestDay === 0){
          hardDayArr = [];
        }

        if(hardestDay === 1&& easiestDay ===1){
          easiestDayArr = [];
        }
        if(a===hardestDay){
          console.log(hardDayArr.length);
          console.log(hardDayArr.reverse().join(" "));
          console.log(easiestDayArr.length);
          console.log(easiestDayArr.join(" "));
        }
        else{
          console.log(easiestDayArr.length);
          console.log(easiestDayArr.join(" "));
          console.log(hardDayArr.length);
          console.log(hardDayArr.reverse().join(" "));

        }
  }

var hours = readline().split(' ').map(v=>+v);
var shorterIndex = +(hours[0] > hours[1]);

var arr = hours[shorterIndex] = {
    nextIndex: 1 - shorterIndex,
    left: - hours[shorterIndex],
    values: []
}, nextObj;

for(var i = 1; true; i++) {
    arr.values.push(i);
    arr.left += i;

    if (arr.left > 0) {
        if (arr.nextIndex === undefined) {
            arr.values.pop();
            break;
        } else {
            arr.values.splice(arr.left - 1, 1)
            arr = nextObj = hours[arr.nextIndex] = {
                left: -hours[arr.nextIndex] + arr.left,
                values: [arr.left]
            };

            if(arr.left > 0) {
                arr.values.pop();
                break;
            }
        }
    }
}

hours.forEach(v => {
    print(v.values.length);
print(v.values.join(' '));
})

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

  let standardInputString= '';
  let currentLine = 0;

  function readLine(){
    return standardInputString[currentLine++];
  }
  process.stdin.on('data', rawData =>{
    standardInputString += rawData;
  });
  process.stdin.on('end', _ =>{
    standardInputString= standardInputString.trim().split('\n').map(line =>{
      return line.trim();
    });

    main();
  })

  function main(){
    let [a,b] = readLine().split(' ').map(Number);
    // let line = readLine().split(' ').map(Number);

      let hardestDay = a>=b ? a : b;
      let easiestDay = a<=b ? a : b;
      let sum = 0;

      let easierSum = 0;

      let hardDayArr = [];
      let easiestDayArr = [];

      let imposterNumber = 0;
      let didOnce = 1;

      let smallestStart = 1;

        for(let j = 1; j<=hardestDay; j++){

          if(sum >= hardestDay){
           imposterNumber = sum - hardestDay;
           if(imposterNumber !== 0){
            hardDayArr.splice(imposterNumber-1,1);
           }
          //  easierSum += imposterNumber + j;
           smallestStart = j;
           break;
          }
          else{
            sum += j;
            hardDayArr.push(j);
          }
        }
        if(imposterNumber !== 0){
          easierSum = imposterNumber
          easiestDayArr.push(easierSum);
        }
        for(smallestStart; smallestStart<=easiestDay; smallestStart++){

          easierSum += smallestStart;
          if(easierSum <= easiestDay){
            easiestDayArr.push(smallestStart);
          }
        }

        if(a===hardestDay){
          console.log(hardDayArr.length);
          console.log(hardDayArr.reverse().join(" "));
          console.log(easiestDayArr.length);
          console.log(easiestDayArr.join(" "));
        }
        else{
          console.log(easiestDayArr.length);
          console.log(easiestDayArr.join(" "));
          console.log(hardDayArr.length);
          console.log(hardDayArr.reverse().join(" "));

        }

  }

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

  let standardInputString= '';
  let currentLine = 0;

  function readLine(){
    return standardInputString[currentLine++];
  }
  process.stdin.on('data', rawData =>{
    standardInputString += rawData;
  });
  process.stdin.on('end', _ =>{
    standardInputString= standardInputString.trim().split('\n').map(line =>{
      return line.trim();
    });

    main();
  })

  function main(){
    let [a,b] = readLine().split(' ').map(Number);
    // let line = readLine().split(' ').map(Number);

      let hardestDay = a>=b ? a : b;
      let easiestDay = a<=b ? a : b;
      let sum = 0;

      let easierSum = 0;

      let hardDayArr = [];
      let easiestDayArr = [];

      let imposterNumber = 0;
      let didOnce = 1;

      let smallestStart = 1;

        for(let j = 1; j<=hardestDay; ++j){

          if(sum >= hardestDay){
           imposterNumber = sum - hardestDay;
           if(imposterNumber !== 0){
            hardDayArr.splice(imposterNumber-1,1);
           }
           smallestStart = j;
           break;
          }
          else{
            sum += j;
            hardDayArr.push(j);
          }
        }
        if(imposterNumber !== 0){
          easierSum = imposterNumber
          easiestDayArr.push(easierSum);
        }
        for(smallestStart; smallestStart<=easiestDay; ++smallestStart){

          easierSum += smallestStart;
          if(easierSum <= easiestDay){
            easiestDayArr.push(smallestStart);
          }
          else{
            break;
          }
        }
        let pera = hardDayArr.length !== 0 ? hardDayArr.reduce((a,b) => a +b) : 0;
        if( pera!== hardestDay){
          hardDayArr.splice((pera - hardestDay) - 1, 1);
        };
        if(a===hardestDay){
          console.log(hardDayArr.length);
          console.log(hardDayArr.join(" "));
          console.log(easiestDayArr.length);
          console.log(easiestDayArr.join(" "));
        }
        else{
          console.log(easiestDayArr.length);
          console.log(easiestDayArr.join(" "));
          console.log(hardDayArr.length);
          console.log(hardDayArr.join(" "));

        }
  }

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

  let standardInputString= '';
  let currentLine = 0;

  function readLine(){
    return standardInputString[currentLine++];
  }
  process.stdin.on('data', rawData =>{
    standardInputString += rawData;
  });
  process.stdin.on('end', _ =>{
    standardInputString= standardInputString.trim().split('\n').map(line =>{
      return line.trim();
    });

    main();
  })

  function main(){
    let [a,b] = readLine().split(' ').map(Number);
    // let line = readLine().split(' ').map(Number);

      let hardestDay = a>=b ? a : b;
      let easiestDay = a<=b ? a : b;
      let sum = 0;

      let easierSum = 0;

      let hardDayArr = [];
      let easiestDayArr = [];

      let imposterNumber = 0;
      let didOnce = 1;

      let smallestStart = 1;

        for(let j = 1; j<=hardestDay; ++j){

          if(sum >= hardestDay){
           imposterNumber = sum - hardestDay;
           if(imposterNumber !== 0){
            hardDayArr.splice(imposterNumber-1,1);
           }
           smallestStart = j;
           break;
          }
          else{
            sum += j;
            hardDayArr.push(j);
          }
        }
        if(imposterNumber !== 0){
          easierSum = imposterNumber
          easiestDayArr.push(easierSum);
        }
        for(smallestStart; smallestStart<=easiestDay; ++smallestStart){

          easierSum += smallestStart;
          if(easierSum <= easiestDay){
            easiestDayArr.push(smallestStart);
          }
          else{
            break;
          }
        }
        let pera = hardDayArr.length !== 0 ? hardDayArr.reduce((a,b) => a +b) : 0;
        if( pera!== hardestDay){
          hardDayArr.splice((pera - hardestDay) - 1, 1);
        };
        if(easiestDay === 0){
          easiestDayArr = [];
        }
        else if( hardestDay === 0){
          hardDayArr = [];
        }
        if(a===hardestDay){
          console.log(hardDayArr.length);
          console.log(hardDayArr.reverse().join(" "));
          console.log(easiestDayArr.length);
          console.log(easiestDayArr.join(" "));
        }
        else{
          console.log(easiestDayArr.length);
          console.log(easiestDayArr.join(" "));
          console.log(hardDayArr.length);
          console.log(hardDayArr.reverse().join(" "));

        }
  }

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

  let standardInputString= '';
  let currentLine = 0;

  function readLine(){
    return standardInputString[currentLine++];
  }
  process.stdin.on('data', rawData =>{
    standardInputString += rawData;
  });
  process.stdin.on('end', _ =>{
    standardInputString= standardInputString.trim().split('\n').map(line =>{
      return line.trim();
    });

    main();
  })

  function main(){
    let [a,b] = readLine().split(' ').map(Number);
    // let line = readLine().split(' ').map(Number);

      let hardestDay = a>=b ? a : b;
      let easiestDay = a<=b ? a : b;
      let sum = 0;

      let easierSum = 0;

      let hardDayArr = [];
      let easiestDayArr = [];

      let imposterNumber = 0;
      let didOnce = 1;

      let smallestStart = 1;

        for(let j = 1; j<=hardestDay; j++){

          if(sum >= hardestDay){
           imposterNumber = sum - hardestDay;
           if(imposterNumber !== 0){
            hardDayArr.splice(imposterNumber-1,1);
           }
          //  easierSum += imposterNumber + j;
           smallestStart = j;
           break;
          }
          else{
            sum += j;
            hardDayArr.push(j);
          }
        }
        if(imposterNumber !== 0){
          easierSum = imposterNumber
          easiestDayArr.push(easierSum);
        }
        for(smallestStart; smallestStart<=easiestDay; smallestStart++){

          easierSum += smallestStart;
          if(easierSum <= easiestDay){
            easiestDayArr.push(smallestStart);
          }
        }

      console.log(easiestDayArr.length);
      console.log(easiestDayArr.join(" "));

      console.log(hardDayArr.length);
      console.log(hardDayArr.join(" "));
  }


'use strict';

function solve(n, m, a) {
  a.sort((a, b) => {
    if (a[0] !== b[0]) return a[0] - b[0];else return b[1] - a[1];
  });
  const nums = new Array(n);
  const segTree = new SegTree(n);
  for (let [l, r, val] of a) {
    segTree.update(l - 1, r - 1, val);
  }
  for (let i = 0; i < n; i++) nums[i] = segTree.query(i);
  let res = 0;
  for (let i = 0; i < 31; i++) {
    for (let j = 0; j < n; j++) {
      if (nums[j] & 1 << i) {
        res = add(res, mul(1 << i, power(2, n - 1)));
        break;
      }
    }
  }
  return res;
}
const MOD = 10 ** 9 + 7;
function mod(num) {
  return (num % MOD + MOD) % MOD;
}
function add(a, b) {
  return mod(mod(a) + mod(b));
}
function power(a, b) {
  let res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b = b >> 1;
  }
  return res;
}
function mul(...args) {
  if (args.length === 0) throw new Error('参数不能为空');
  if (args.length === 1) return args[0];
  const [a, b] = args;
  if (args.length > 2) return mul(mul(a, b), ...args.slice(2));
  return (Math.floor(a / 65536) * b % MOD * 65536 + (a & 65535) * b) % MOD;
}
class SegTree {
  constructor(n) {
    this.n = n;
    this.root = this._newNode();
    this.update = (x, y, z) => {
      x = Math.max(x, 0);
      y = Math.min(y, n);
      this._update(this.root, 0, n, x, y, z);
    };
    this.query = x => {
      x = Math.max(x, 0);
      x = Math.min(x, n);
      return this._query(this.root, 0, n, x);
    };
  }
  _newNode(val = 0, left = null, right = null) {
    return {
      val,
      left,
      right,
      add: 0
    };
  }
  _down(node, l, r) {
    const {
      left,
      right
    } = node;
    if (!left || !right) return;
    if (node.add) {
      left.add = node.add;
      left.val = node.add;
      right.add = node.add;
      right.val = node.add;
      node.add = 0;
    }
  }
  _update(node, l, r, x, y, z) {
    if (!node) return;
    if (l === x && r === y) {
      node.add = z;
      node.val = z;
      return;
    }
    const mid = Math.floor((l + r) / 2);
    if (!node.left) {
      node.left = this._newNode();
      node.right = this._newNode();
    }
    this._down(node, l, r);
    if (y <= mid) this._update(node.left, l, mid, x, y, z);else if (x > mid) this._update(node.right, mid + 1, r, x, y, z);else this._update(node.left, l, mid, x, mid, z), this._update(node.right, mid + 1, r, mid + 1, y, z);
  }
  _query(node, l, r, x) {
    if (!node) return 0;
    if (l === r) return node.val;
    let res = 0,
        mid = Math.floor((l + r) / 2);
    if (!node.left) {
      node.left = this._newNode();
      node.right = this._newNode();
    }
    this._down(node, l, r);
    if (x <= mid) res = this._query(node.left, l, mid, x);else res = this._query(node.right, mid + 1, r, x);
    return res;
  }
}

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

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader ();

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});
	const mod = 1e9 + 7;
	let t = inputReader.readNumber();

	function solve() {
	  let [n, m] = inputReader.readNumberArray();
	  let totalOr = 0;
	  while (m--) {
	    let [l, r, or] = inputReader.readNumberArray();
	    totalOr |= or;
	  }
	  totalOr %= mod;
	  for (let i = 1; i <= n - 1; i++) totalOr = (2 * totalOr) % mod;
	  console.log(totalOr);
	}

	while (t--) {
	  solve();
	}

}

var _inputData = '';
function cacheInput(data) {
	_inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', cacheInput).on('end', _main);

function _inputReader () {
	function readNumber(){
		return Number(_inputLines[_lineNumber++]);
	}

	function readNumberArray(){
		return _inputLines[_lineNumber++].split(' ').map(val => Number(val));
	}

	return {
		readNumber,
		readNumberArray,
	}
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(Number)
        const or = lines.slice(l, l + m).map(str => str.trim().split(' ').map(Number))
        l += m
        output[i] = solve(n, m, or)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, m, or) {
    const arr = Array(n).fill(0)
    or.forEach(([l, r, x]) => {
        arr[l - 1] |= x
        arr[r - 1] |= x
    })
// const arr = [0, 2]
// const arr = [5, 6, 7, 0, 2]
    let prev
    let limit = 1
    let ans = 0
    for (let i = 0; i < arr.length; i++) {
        const next = []
        for (let j = 0; j < 30; j++) {
            if (arr[i] & (1 << j)) {
                if (i) {
                    next[j] = minus(limit, prev[j])
                    next[j] = add(next[j], prev[j])
                } else {
                    next[j] = limit
                }
            } else {
                if (i) {
                    next[j] = prev[j]
                    next[j] = add(next[j], prev[j])
                } else {
                    next[j] = 0
                }
            }
            if (i === arr.length - 1) {
                ans = add(ans, mul(next[j], 1 << j))
            }
        }
        limit = mul(limit, 2)
        prev = next
// console.log(prev)
    }

    return ans
}
function add(a, b) {
    return (a + b) % (1e9 + 7)
}
function minus(a, b) {
    return (a - b + 1e9 + 7) % (1e9 + 7)
}
function mul(a, b) {
    let r = 0
    let base = a
    while (b) {
        if (b & 1) {
            r = add(r, base)
        }
        b >>= 1
        base = add(base, base)
    }
    return r
}

'use strict';

function solve(n, m, a) {
  let num = a.reduce((a, b) => a | b[2], 0);
  let res = 0;
  for (let i = 0; i < 31; i++) {
    if (num & 1 << i) {
      res = add(res, mul(1 << i, power(2, n - 1)));
    }
  }
  return res;
}
const MOD = 10 ** 9 + 7;
function mod(num) {
  return (num % MOD + MOD) % MOD;
}
function add(a, b) {
  return mod(mod(a) + mod(b));
}
function power(a, b) {
  let res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b = b >> 1;
  }
  return res;
}
function mul(...args) {
  if (args.length === 0) throw new Error('参数不能为空');
  if (args.length === 1) return args[0];
  const [a, b] = args;
  if (args.length > 2) return mul(mul(a, b), ...args.slice(2));
  return (Math.floor(a / 65536) * b % MOD * 65536 + (a & 65535) * b) % MOD;
}

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

function solve(n, m, a) {
  a.sort((a, b) => {
    if (a[0] !== b[0]) return a[0] - b[0];else return b[1] - a[1];
  });
  const nums = new Array(n);
  const segTree = new SegTree(n);
  for (let [l, r, val] of a) {
    segTree.update(l - 1, r - 1, val);
  }
  for (let i = 0; i < n; i++) nums[i] = segTree.query(i);
  let res = 0;
  for (let i = 0; i < 31; i++) {
    for (let j = 0; j < n; j++) {
      if (nums[j] & 1 << i) {
        res = res + (1 << i) * 2 ** (n - 1);
        break;
      }
    }
  }
  return res;
}
class SegTree {
  constructor(n) {
    this.n = n;
    this.root = this._newNode();
    this.update = (x, y, z) => {
      x = Math.max(x, 0);
      y = Math.min(y, n);
      this._update(this.root, 0, n, x, y, z);
    };
    this.query = x => {
      x = Math.max(x, 0);
      x = Math.min(x, n);
      return this._query(this.root, 0, n, x);
    };
  }
  _newNode(val = 0, left = null, right = null) {
    return {
      val,
      left,
      right,
      add: 0
    };
  }
  _down(node, l, r) {
    const {
      left,
      right
    } = node;
    if (!left || !right) return;
    if (node.add) {
      left.add = node.add;
      left.val = node.add;
      right.add = node.add;
      right.val = node.add;
      node.add = 0;
    }
  }
  _update(node, l, r, x, y, z) {
    if (!node) return;
    if (l === x && r === y) {
      node.add = z;
      node.val = z;
      return;
    }
    const mid = Math.floor((l + r) / 2);
    if (!node.left) {
      node.left = this._newNode();
      node.right = this._newNode();
    }
    this._down(node, l, r);
    if (y <= mid) this._update(node.left, l, mid, x, y, z);else if (x > mid) this._update(node.right, mid + 1, r, x, y, z);else this._update(node.left, l, mid, x, mid, z), this._update(node.right, mid + 1, r, mid + 1, y, z);
  }
  _query(node, l, r, x) {
    if (!node) return 0;
    if (l === r) return node.val;
    let res = 0,
        mid = Math.floor((l + r) / 2);
    if (!node.left) {
      node.left = this._newNode();
      node.right = this._newNode();
    }
    this._down(node, l, r);
    if (x <= mid) res = this._query(node.left, l, mid, x);else res = this._query(node.right, mid + 1, r, x);
    return res;
  }
}

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

function solve(n, m, a) {
  a.sort((a, b) => {
    if (a[0] !== b[0]) return a[0] - b[0];else return b[1] - a[1];
  });
  const nums = new Array(n);
  const segTree = new SegTree(n);
  for (let [l, r, val] of a) {
    segTree.update(l - 1, r - 1, val);
  }
  for (let i = 0; i < n; i++) nums[i] = segTree.query(i);
  let res = 0;
  for (let i = 0; i < 31; i++) {
    for (let j = 0; j < n; j++) {
      if (nums[i] & 1 << i) {
        res = add(res, mul(1 << i, power(2, n - 1)));
        break;
      }
    }
  }
  return res;
}
const MOD = 10 ** 9 + 7;
function mod(num) {
  return (num % MOD + MOD) % MOD;
}
function add(a, b) {
  return mod(mod(a) + mod(b));
}
function power(a, b) {
  let res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b = b >> 1;
  }
  return res;
}
function mul(...args) {
  if (args.length === 0) throw new Error('参数不能为空');
  if (args.length === 1) return args[0];
  const [a, b] = args;
  if (args.length > 2) return mul(mul(a, b), ...args.slice(2));
  return (Math.floor(a / 65536) * b % MOD * 65536 + (a & 65535) * b) % MOD;
}
class SegTree {
  constructor(n) {
    this.n = n;
    this.root = this._newNode();
    this.update = (x, y, z) => {
      x = Math.max(x, 0);
      y = Math.min(y, n);
      this._update(this.root, 0, n, x, y, z);
    };
    this.query = x => {
      x = Math.max(x, 0);
      x = Math.min(x, n);
      return this._query(this.root, 0, n, x);
    };
  }
  _newNode(val = 0, left = null, right = null) {
    return {
      val,
      left,
      right,
      add: 0
    };
  }
  _down(node, l, r) {
    const {
      left,
      right
    } = node;
    if (!left || !right) return;
    if (node.add) {
      left.add = node.add;
      left.val = node.add;
      right.add = node.add;
      right.val = node.add;
      node.add = 0;
    }
  }
  _update(node, l, r, x, y, z) {
    if (!node) return;
    if (l === x && r === y) {
      node.add = z;
      node.val = z;
      return;
    }
    const mid = Math.floor((l + r) / 2);
    if (!node.left) {
      node.left = this._newNode();
      node.right = this._newNode();
    }
    this._down(node, l, r);
    if (y <= mid) this._update(node.left, l, mid, x, y, z);else if (x > mid) this._update(node.right, mid + 1, r, x, y, z);else this._update(node.left, l, mid, x, mid, z), this._update(node.right, mid + 1, r, mid + 1, y, z);
  }
  _query(node, l, r, x) {
    if (!node) return 0;
    if (l === r) return node.val;
    let res = 0,
        mid = Math.floor((l + r) / 2);
    if (!node.left) {
      node.left = this._newNode();
      node.right = this._newNode();
    }
    this._down(node, l, r);
    if (x <= mid) res = this._query(node.left, l, mid, x);else res = this._query(node.right, mid + 1, r, x);
    return res;
  }
}

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

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader();

function _main() {
  _inputLines = _inputData
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });
  const mod = 1e9 + 7;
  let t = inputReader.readNumber();

  function modPower(x, y, mod) {
    let res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0) {
      if (y & 1) res = (res * x) % mod;
      y = y >> 1;
      x = (x * x) % mod;
    }
    return res;
  }

  function solve() {
    let [n, m] = inputReader.readNumberArray();
    let totalOr = 0;
    while (m--) {
      let [l, r, or] = inputReader.readNumberArray();
      totalOr |= or;
    }
    totalOr %= mod;
    let ans = totalOr * modPower(2, n - 1, mod);
    console.log(ans);
  }

  while (t--) {
    solve();
  }
}

var _inputData = "";
function cacheInput(data) {
  _inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", cacheInput).on("end", _main);

function _inputReader() {
  function readNumber() {
    return Number(_inputLines[_lineNumber++]);
  }

  function readNumberArray() {
    return _inputLines[_lineNumber++].split(" ").map((val) => Number(val));
  }

  return {
    readNumber,
    readNumberArray,
  };
}

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader();

function _main() {
  _inputLines = _inputData
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });
  const mod = 1e9 + 7;
  let t = inputReader.readNumber();

  function modPower(x, y, mod) {
    let res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0) {
      if (y & 1) res = (res * x) % mod;
      y = y >> 1;
      x = (x * x) % mod;
    }
    return res;
  }

  function solve() {
    let [n, m] = inputReader.readNumberArray();
    let totalOr = 0;
    while (m--) {
      let [l, r, or] = inputReader.readNumberArray();
      totalOr |= or;
    }
    let ans = totalOr * modPower(2, n - 1, mod);
    console.log(ans);
  }

  while (t--) {
    solve();
  }
}

var _inputData = "";
function cacheInput(data) {
  _inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", cacheInput).on("end", _main);

function _inputReader() {
  function readNumber() {
    return Number(_inputLines[_lineNumber++]);
  }

  function readNumberArray() {
    return _inputLines[_lineNumber++].split(" ").map((val) => Number(val));
  }

  return {
    readNumber,
    readNumberArray,
  };
}


//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();
	var map = {};
	var sosu = Array.from(sieveOfEratos(30000));
	sosu.sort(function(a,b){
		return a - b;
	});
	for(var i = 0; i < t; i++){
		var d = nextInt();
		if(map[d] != null){
			myout(map[d]);
			continue;
		}
		var L = 0;
		var index = -1;
		for(var j = 0; j < sosu.length; j++){
			if(sosu[j] > d){
				index = j;
				L = sosu[j];
				break;
			}
		}
		var R = 0;
		for(var j = index + 1; j < sosu.length; j++){
			if(sosu[j] - L >= d){
				R = sosu[j];
				break;
			}
		}
		myout(L * R);
		map[d] = L * R;
	}
}
function isPrime(val){
  if(val == null || val <= 1 || (val != 2 && val % 2 == 0)){
    return false;
  }else if(val == 2){
    return true;
  }
  var root = Math.floor(Math.sqrt(val));
  for(var i = 3; i <= root; i += 2){
    if(val % i == 0){
      return false;
    }
  }
  return true;
}
function sieveOfEratos(val){
  var primes = new Set();
  var nums = new Set();
  var used = [2,3,5,7,11];//これらは既に素数であるとする
  var underPrime = 13;//この値から+2ごとに追加。↑の値で割り切れたものは何もしない
  if(val <= 1){
     return nums;
  }
  for(var i = 0; i < used.length; i++){if(used[i] <= val){nums.add(used[i]);}}
  for(var i = underPrime; i <= val; i = i + 2){
    var continued = false;
    for(var j = 0; j < used.length; j++){
      if(i % used[j] == 0){continued = true; break;}
    }
    if(continued){continue;}
    nums.add(i);
  }
  for(var i = 2; i <= Math.sqrt(val); (i == 2) ? i++ : i = i + 2){
    if(!nums.has(i)){continue;}
    var count = 1;
    while(i * count <= val){
      if(i <= 11 && used.indexOf(i) != -1){break;}
      if(count == 1){primes.add(i);}
      nums.delete(i * count);
      count++;
    }
  }
  var primeItr = Array.from(primes);
  for(var i = 0; i < primeItr.length; i++){
    nums.add(primeItr[i]);
  }
  return nums;
}

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();
	const map = new Map();
	const primes = [2];
	const isPrime = Array(1e5).fill(1);

	for (let i = 3; i <= 1e5; i += 2) {
		if (isPrime[i] === 1) {
			primes.push(i);
			for (let j = i + i; j <= 1e5; j += i) {
				isPrime[j] = 0;
			}
		}
	}
	while (t--) {
		const n = +readLine();
		if (map.has(n)) console.log(map.get(n));
		else {
			const a = immediateGreaterValue(primes, n);
			const b = immediateGreaterValue(primes, a + n - 1);
			map.set(n, a * b);
			console.log(a * b);

			function immediateGreaterValue(arr, target) {
				let [left, right] = [0, arr.length - 1];
				while (left <= right) {
					const mid = left + Math.floor((right - left) / 2);
					if (arr[mid] > target) right = mid - 1;
					else left = mid + 1;
				}
				return arr[left];
			}
		}
	}
}

'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 x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var n = Number(readline());
        var d =n+1
        sumDivisors(d*d*d, n)
        // console.log((1+n)*(1+2*n))

    })

}

function sumDivisors(n, d) {
    var sum = 0;
    var nn = 1+d
    while(!isPrime(nn)) nn++
    var nn2 = nn+d
    while(!isPrime(nn2)) nn2++

    console.log(nn2*nn)
}
function isPrime(num) {
    for(var i = 2; i < num; i++)
        if(num % i === 0) return false;
    return num > 1;
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  const checkPrime = (n) => {
    for (let i = 2; i * i <= n; i++) {
      if (n % i === 0) return false;
    }
    return true;
  };
  while (t--) {
    let n = parseInt(readline());
    let c = n + 1;
    while (true) {
      if (checkPrime(c)) break;
      c++;
    }
    let res = c;
    c = c + n;
    while (true) {
      if (checkPrime(c)) break;
      c++;
    }
    console.log(res * c);
  }
};
solve();

'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 n = readline() // .split(' ')
    // let n = line[0]
    // let k = line[1]
    // let ans = ''
    let first = 0, second = 0
    // ------------------
    // console.log('n = ', n)
    let num = 1 + parseInt(n)
    while ( first == 0) {
        first = isPrime(num)
        num++
    }
    // console.log('first = ', first)
    num += n - 1
    while ( second == 0) {
        second = isPrime(num)
        num++
    }
    // console.log('second = ', second)
    console.log(first * second)
}

function isPrime (num) {
    // console.log('isPrime num = ', num)
    if (num == 2)
        return 2
    if (num % 2 == 0)
        return 0
    else {
        if (num == 3)
            return 3

        let limit = parseInt(Math.sqrt(num))
        let i = 0
        for ( i = 3; i <= limit; i += 2) {
            if (num % i == 0)
                return 0
        }
        // console.log('i = ', i)
        return num
    }
}

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

const isPrime = n => {
  for (let index = 2; index < Math.ceil(Math.floor(n)); index++) {
    if (n % index === 0) return false
  }
  return true
}

const calculate = d => {
  let first = 1 + d
  while (!isPrime(first)) {
    first++
  }

  let second = first + d
  while (!isPrime(second)) {
    second++
  }

  return first * second
}

let index = -1
let maxRound = 0
let round = 0

let d
let answer = []

readline.on('line', line => {
  if (index === -1) {
    maxRound = Number(line)
    index = 0
  } else {
    d = Number(line)

    answer.push(calculate(d))

    round++
    if (round === maxRound) {
      readline.close()
      console.log(answer.join('\n'))
      return
    }
    index++
  }
})
// console.log(calculate(6, 5, [1, 2, 3, 3, 2, 1]))

"use strict"

let iter = parseInt(readline());

for(iter; iter > 0; iter--){
    let n = parseInt(readline());

    let temp = findNextPrime(1, n)
    let res = temp * findNextPrime(temp, n)
    print(res)
}

function findNextPrime(n, d){
    for(let i = n + d;; i++){
        if(isPrime(i)) return i;
    }
}

function isPrime(n){
    for(let i = 2; i <= Math.sqrt(n); i++){
        if(n % i === 0) return false;
    }
    return true;
}

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--) {
		const n = +readLine();
		const [a, b] = [1 + n, 1 + 2 * n];
		console.log(a * b);
	}
}

'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 x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var n = Number(readline());
        console.log((1+n)*(1+2*n))

    })

}


const rubleCount = Number(readline());
const dollarPrice = Number(readline());
const euroPrice = Number(readline()) * 5;
var result = rubleCount;
for (var i = 0;; i++) {
  var remaining = rubleCount - i * dollarPrice;
  if (remaining < 0) break;
  var cur = remaining % euroPrice;
  if (cur < result) result = cur;
}
print(result);

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

var main = function() {"use strict";
    // TODO
    var n = rdN();
    var d = rdN();
    var e = rdN();

    var d1 = d;
    var e5 = e*5;

    var a = Math.floor(n / d1);
    var b = 0;
    var res = n%d1;

    while (a >= 0) {
        var s = a*d1 + b*e5;
        if (s <= n) {
            res = Math.min(res, n - s);
            ++b;
        } else {
            --a;
        }
    }

    wr(res);
};

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

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

var main = function() {"use strict";
    // TODO
    var n = rdN();
    var d = rdN();
    var e = rdN();

    var d1 = d;
    var e5 = e*5;
    var b = Math.max(d1,e5);
    var s = Math.min(d1,e5);
    var diff = b - s;

    var res1 = n%b;
    res1 %= s;

    var res2 = n%s;
    res2 %= diff;
    wr(Math.min(res1, res2));
};

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

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

var main = function() {"use strict";
    // TODO
    var n = rdN();
    var d = rdN();
    var e = rdN();

    var d1 = d;
    var e5 = e*5;

    var a = Math.floor(n / d1);
    var b = 0;
    var res = n%d1;

    while (a > 0) {
        var s = a*d1 + b*e5;
        if (s <= n) {
            res = Math.min(res, n - s);
            ++b;
        } else {
            --a;
        }
    }

    wr(res);
};

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

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

var main = function() {"use strict";
    // TODO
    var n = rdN();
    var d = rdN();
    var e = rdN();

    var d1 = d;
    var e5 = e*5;

    wr(Math.min(n%d1%e5, n%e5%d1));
};

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

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

var main = function() {"use strict";
    // TODO
    var n = rdN();
    var d = rdN();
    var e = rdN();

    var d1 = d;
    var e5 = e*5;

    wr(Math.min([n%d1%e5, n%e5%d1]));
};

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