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

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

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

function main() {
	var numItems = parseInt(readline(), 10),
		desiredOrder = tokenizeIntegers(readline()),
		actualOrder = tokenizeIntegers(readline()),
		versionLookup = {},
		uniques = [],
		positionOf = {};

	function buildVersionString(item) {
		return item + "." + versionLookup[item];
	}

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		var item = desiredOrder[itemIndex];
		if (versionLookup[item] == undefined) {
			uniques.push(item);
			versionLookup[item] = 0;
		}
		else {
			versionLookup[item] += 1;
		}

		positionOf[buildVersionString(item)] = itemIndex;
	}

	for (var uniqueIndex = uniques.length-1; uniqueIndex >= 0; --uniqueIndex) {
		versionLookup[uniques[uniqueIndex]] = undefined;
	}

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		var item = actualOrder[itemIndex];
		if (versionLookup[item] == undefined) {
			versionLookup[item] = 0;
		}
		else {
			versionLookup[item] += 1;
		}

		actualOrder[itemIndex] = positionOf[buildVersionString(item)];
	}

	var swaps = [];

	while (true) {
		var madeSwap = (1 == 2);

		for (var itemIndex = 1; itemIndex < numItems; ++itemIndex) {
			if (actualOrder[itemIndex-1] > actualOrder[itemIndex]) {
				var temp = actualOrder[itemIndex-1];
				actualOrder[itemIndex-1] = actualOrder[itemIndex];
				actualOrder[itemIndex] = temp;

				madeSwap = true;
				swaps.push((itemIndex) + " " + (itemIndex+1));
			}
		}// end for

		if (madeSwap == false) {
			break;
		}
	}// end while

	swaps.unshift(swaps.length);
	print(swaps.join("\n"));
}// end main

main();

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

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

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

function main() {
	var numItems = parseInt(readline(), 10),
		desiredOrder = tokenizeIntegers(readline()),
		actualOrder = tokenizeIntegers(readline()),
		versionLookup = {},
		uniques = [],
		positionOf = {};

	function buildVersionString(item) {
		return item + "." + versionLookup[item];
	}

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		var item = desiredOrder[itemIndex];
		if (versionLookup[item] == undefined) {
			uniques.push(item);
			versionLookup[item] = 0;
		}
		else {
			versionLookup[item] += 1;
		}

		positionOf[buildVersionString(item)] = itemIndex;
	}

	for (var uniqueIndex = uniques.length-1; uniqueIndex >= 0; --uniqueIndex) {
		versionLookup[uniques[uniqueIndex]] = undefined;
	}

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		var item = actualOrder[itemIndex];
		if (versionLookup[item] == undefined) {
			versionLookup[item] = 0;
		}
		else {
			versionLookup[item] += 1;
		}

		actualOrder[itemIndex] = positionOf[buildVersionString(item)];
	}

	var swaps = [];

	while (true) {
		var madeSwap = (1 == 0);

		for (var itemIndex = 1; itemIndex < numItems; ++itemIndex) {
			if (actualOrder[itemIndex-1] > actualOrder[itemIndex]) {
				var temp = actualOrder[itemIndex-1];
				actualOrder[itemIndex-1] = actualOrder[itemIndex];
				actualOrder[itemIndex] = temp;

				madeSwap = true;
				swaps.push((itemIndex) + " " + (itemIndex+1));
			}
		}// end for

		if (madeSwap == false) {
			break;
		}
	}// end while

	swaps.unshift(swaps.length);
	print(swaps.join("\n"));
}// end main

main();

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

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

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

function main() {
	var numItems = parseInt(readline(), 10),
		desiredOrder = tokenizeIntegers(readline()),
		actualOrder = tokenizeIntegers(readline()),
		versionLookup = {},
		uniques = [],
		positionOf = {};

	function buildVersionString(item) {
		return item + "." + versionLookup[item];
	}

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		var item = desiredOrder[itemIndex];
		if (versionLookup[item] == undefined) {
			uniques.push(item);
			versionLookup[item] = 0;
		}
		else {
			versionLookup[item] += 1;
		}

		positionOf[buildVersionString(item)] = itemIndex;
	}

	for (var uniqueIndex = uniques.length-1; uniqueIndex >= 0; --uniqueIndex) {
		versionLookup[uniques[uniqueIndex]] = undefined;
	}

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		var item = actualOrder[itemIndex];
		if (versionLookup[item] == undefined) {
			versionLookup[item] = 0;
		}
		else {
			versionLookup[item] += 1;
		}

		actualOrder[itemIndex] = positionOf[buildVersionString(item)];
	}

	var swaps = [];

	while (true) {
		var madeSwap = false;

		for (var itemIndex = 1; itemIndex < numItems; ++itemIndex) {
			if (actualOrder[itemIndex-1] > actualOrder[itemIndex]) {
				var temp = actualOrder[itemIndex-1];
				actualOrder[itemIndex-1] = actualOrder[itemIndex];
				actualOrder[itemIndex] = temp;

				madeSwap = true;
				swaps.push((itemIndex) + " " + (itemIndex+1));
			}
		}// end for

		if (madeSwap == false) {
			break;
		}
	}// end while

	swaps.unshift(swaps.length);
	print(swaps.join("\n"));
}// end main

main();

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

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

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

function main() {
	var numItems = parseInt(readline(), 10),
		desiredOrder = tokenizeIntegers(readline()),
		actualOrder = tokenizeIntegers(readline()),
		versionLookup = {},
		uniques = [],
		positionOf = {};

	function buildVersionString(item) {
		return item + "." + versionLookup[item];
	}

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		var item = desiredOrder[itemIndex];
		if (versionLookup[item] == undefined) {
			uniques.push(item);
			versionLookup[item] = 0;
		}
		else {
			versionLookup[item] += 1;
		}

		positionOf[buildVersionString(item)] = itemIndex;
	}

	for (var uniqueIndex = uniques.length-1; uniqueIndex >= 0; --uniqueIndex) {
		versionLookup[uniques[uniqueIndex]] = undefined;
	}

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		var item = actualOrder[itemIndex];
		if (versionLookup[item] == undefined) {
			versionLookup[item] = 0;
		}
		else {
			versionLookup[item] += 1;
		}

		actualOrder[itemIndex] = positionOf[buildVersionString(item)];
	}

	var swaps = new Array();

	while (true) {
		var madeSwap = false;

		for (var itemIndex = 1; itemIndex < numItems; ++itemIndex) {
			if (actualOrder[itemIndex-1] > actualOrder[itemIndex]) {
				var temp = actualOrder[itemIndex-1];
				actualOrder[itemIndex-1] = actualOrder[itemIndex];
				actualOrder[itemIndex] = temp;

				madeSwap = true;
				swaps.push((itemIndex) + " " + (itemIndex+1));
			}
		}// end for

		if (madeSwap == false) {
			break;
		}
	}// end while

	swaps.unshift(swaps.length);
	print(swaps.join("\n"));
}// end main

main();

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

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

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

function main() {
	var numItems = parseInt(readline(), 10),
		desiredOrder = tokenizeIntegers(readline()),
		actualOrder = tokenizeIntegers(readline()),
		itemInfo = {};

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		var item = desiredOrder[itemIndex];
		if (itemInfo[item] == undefined) {
			itemInfo[item] = {
				occurrences: [itemIndex],
				occurrenceIndex: 0
			};
		}
		else {
			itemInfo[item].occurrences.push(itemIndex);
		}
	}

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		var item = actualOrder[itemIndex];

		actualOrder[itemIndex] = itemInfo[item].occurrences[
			itemInfo[item].occurrenceIndex++];
	}

	var swaps = [];

	while (true) {
		var madeSwap = (1+2 == 2);

		for (var itemIndex = 1; itemIndex < numItems; ++itemIndex) {
			if (actualOrder[itemIndex-1] > actualOrder[itemIndex]) {
				var temp = actualOrder[itemIndex-1];
				actualOrder[itemIndex-1] = actualOrder[itemIndex];
				actualOrder[itemIndex] = temp;

				madeSwap = true;
				swaps.push((itemIndex) + " " + (itemIndex+1));
			}
		}// end for

		if (madeSwap == false) {
			break;
		}
	}// end while

	swaps.unshift(swaps.length);
	print(swaps.join("\n"));
}// end main

main();


function main() {
  var n = +next(), m = +next();
  if (m != n - 1) {
    print("no");
    return;
  }
  var p = [];
  var i;
  for (i = -1; ++ i < n; ) p[i] = i;
  function findp(u) { return (p[u] = u === p[u] ? u : findp(p[u])); }
  function join(u, v) { p[findp(u)] = findp(v); }

  while (m--) {
    join(next() - 1, next() - 1);
  }
  var cnt = 0;
  for (i = -1; ++i < n; )
    cnt += +(i === findp(i));
  print(cnt === 1 ? "yes" : "no");
}

var line = null, linepos = 0;
function next() {
  if (!line || linepos === line.length) {
    line = readline().split(' ');
    linepos = 0;
  }
  return line[linepos++];
}

if (typeof readline == 'undefined') {
  process.stdin.resume();
  process.stdin.setEncoding('ascii');

  var input_stdin = "";
  process.stdin.on('data', function (data) { input_stdin += data; });
  process.stdin.on('end', function () {
    // input_stdin = input_stdin.split(/\s/);
    input_stdin = input_stdin.split('\n');
    var curline = 0;
    readline = () => input_stdin[curline++];
    if (typeof print == 'undefined') print = console.log;
    main();
  });
} else main();

function getNumberArray() {
    return readline().split(" ").map(function(s) { return Number(s); });
}

var nm = getNumberArray();
var n = nm[0], m = nm[1];

function p(brain) {
    if (subtree[brain] == brain)
        return brain;

    subtree[brain] = p(subtree[brain]);
    return subtree[brain];
}

var subtree = new Array(n); // subtree index for all brains
for (var i = 0; i < n; ++i)
    subtree[i] = i;

if (m != n - 1)
    print("no");
else {

    for (var j = 0; j < m; ++j) {
        var ab = getNumberArray();
        var a = ab[0] - 1, b = ab[1] - 1;

        var k1 = Math.min(p(a), p(b));
        var k2 = Math.max(p(a), p(b));
        //print(a, "<-->", b, " (", k1, "<>", k2, ")");

        subtree[k2] = k1;
    }

    var success = true;
    for (var i = 0; i < n; ++i)
        if (p(i) !== 0) {
            success = false;
            break;
        }

    print(success ? "yes" : "no");
}

function getNumberArray() {
    return readline().split(" ").map(function(s) { return Number(s); });
}

var nm = getNumberArray();
var n = nm[0], m = nm[1];

function p(brain) {
    if (subtree[brain] == brain)
        return brain;

    subtree[brain] = p(subtree[brain]);
    return subtree[brain];
}

if (m != n - 1)
    print("no");
else {
    var subtree = new Array(n); // subtree index for all brains
    for (var i = 0; i < n; ++i)
        subtree[i] = i;

    for (var j = 0; j < m; ++j) {
        var ab = getNumberArray();
        var a = ab[0], b = ab[1];

        if (a > b) {
            var tmp = a;
            a = b;
            b = tmp;
        }
        //print(a, "<-->", b);

        subtree[b - 1] = a - 1;
    }

    var success = true;
    for (var i = 0; i < n; ++i)
        if (p(i) !== 0) {
            success = false;
            break;
        }

    print(success ? "yes" : "no");
}


let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
     var n = lines[0]
    for(j = 1; j <= n; j++){
        var s = lines[j].split(' ').map(Number)
        var a = s[0]
        var m = s[1]
        if(a == 1 && m == 1){
            console.log(0)
        }else if(a == 1 || m == 1){
            console.log(1)
        }else{
            console.log(2)
        }
    }
});

n = readline();
while (n--) {
  s = readline().split(" ");
  x = +s[0];
  y = +s[1];
  if (x == 1 && y == 1) print(0);
  else if (x == 1 || y == 1) print(1);
  else print(2);
}

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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const [n, m] = rna();

		if (n == 1 && m == 1) console.log(0);
		else if (n == 1 || m == 1) console.log(1);
		else console.log(2);
	}
}

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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let t = rn();
	while (t--) {
		let [n, m] = rna();

		if (n == 1 && m == 1) console.log(0);
		else if (n == 1 || m == 1) console.log(1);
		else console.log(2);
	}
}

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

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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const [n, m] = rna();

		if (n == 1 || m == 1) console.log(1);
		else console.log(2);
	}
}

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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let t = rn();
	while (t--) {
		let [n, m] = rna();

		if (n == 1 || m == 1) console.log(1);
		else console.log(2);
	}
}

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

n = readline();
while (n--) {
  s = readline().split(" ");
  x = +s[0];
  y = +s[1];
  print(x < y ? x : y);
}


print(function(n) {

	var ans = [],
		sum = 0;
	while (n--)
		ans.push(readline().split(' ').map(Number).reduce(function(a, g) {
			if (sum + a <= 500) {
				sum += a;
				return 'A';
			}
			sum -= g;
			return 'G';
		}));

	return ans.join('');

}(+readline()));

;(function () {

	print(function (n) {

		var a = 0, b = 0, result = '';
		while (n--) {
			var l = readline().split(' ').map(Number),
				_a = a + l[0], _b = b + l[1];

			if (Math.abs(_b - a) < Math.abs(_a - b)) {
				b = _b; result += 'G';
			} else {
				a = _a; result += 'A';
			}
		}

		return Math.abs(a - b) > 500 ? -1 : result;

	}(+readline()));

}.call(this));

;(function () {

	print(function (n) {

		var a = 0, b = 0, result = '';
		while (n--) {
			var l = readline().split(' ').map(Number),
				_a = a + l[0], _b = b + l[1];

			if (Math.abs(_b - a) < Math.abs(_a - b)) {
				b = _b; result += 'B';
			} else {
				a = _a; result += 'A';
			}
		}

		return Math.abs(a - b) > 500 ? -1 : result;

	}(+readline()));

}.call(this));


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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

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

		let mni = 0;
		for (let i = 0; i < n; i++) {
			if (a[i] < a[mni]) {
				mni = i;
			}
		}

		console.log(n-1);
		for(let i = 1; i < n; i++) {
			if (i != mni) {
				console.log(mni+1, i+1, a[mni], a[mni]+i);
			}
		}
		if (mni != 0)
			console.log(mni+1, 1, a[mni]+mni, a[mni]);
	}
}

"use strict";

var t = parseInt(readline(), 10);

for (; t > 0; --t) {
  var n = parseInt(readline(), 10);
  var arr = readline().split(" ").map(function (v) {
    return parseInt(v, 10);
  });

  if (n === 1) {
    print(0);
    continue;
  } // 找到最小值

  var minn = Math.min.apply(null, arr); // 找到最小值的（第一个）索引

  var mini = arr.indexOf(minn);
  print(n - 1); // 向左

  var add = 0;

  for (var i = mini - 1; i >= 0; --i) {
    ++add;
    print("".concat(mini + 1, " ").concat(i + 1, " ").concat(minn, " ").concat(minn + add));
  } // 向右

  add = 0;

  for (var _i = mini + 1; _i < n; ++_i) {
    ++add;
    print("".concat(mini + 1, " ").concat(_i + 1, " ").concat(minn, " ").concat(minn + add));
  }
}

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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

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

		let mni = 0;
		for (let i = 0; i < n; i++) {
			if (a[i] < a[mni]) {
				mni = i;
			}
		}

		console.log(n-1);
		for(let i = 0; i < n; i++) {
			if (i == mni) continue;
			console.log(mni+1, i+1, a[mni], a[mni] + Math.abs(i-mni));
		}
	}
}

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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

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

		let mni = 0;
		for (let i = 0; i < n; i++) {
			if (a[i] < a[mni]) {
				mni = i;
			}
		}

		console.log(mni == 0 ? n-1: n);
		if (mni != 0) console.log(1, mni+1, a[mni], a[0]);
		for(let i = 1; i < n; i++) {
			console.log(1, i+1, a[mni], a[mni]+i);
		}
	}
}

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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

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

		let mni = 0;
		for (let i = 0; i < n; i++) {
			if (a[i] < a[mni]) {
				mni = i;
			}
		}

		console.log(n);
		if (mni != 0) console.log(1, mni+1, a[mni], a[0]);
		for(let i = 1; i < n; i++) {
			console.log(1, i+1, a[mni], a[mni]+i);
		}
	}
}

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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

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

		let mni = 0;
		for (let i = 0; i < n; i++) {
			if (a[i] < a[mni]) {
				mni = i;
			}
		}

		console.log(mni == 0 ? n-2 : n-1);
		for(let i = 1; i < n; i++) {
			if (i != mni) {
				console.log(mni+1, i+1, a[mni], a[mni]+i);
			}
		}
		if (mni != 0)
			console.log(mni+1, 1, a[mni]+mni, a[mni]);
	}
}

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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

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

		let mni = 0;
		for (let i = 0; i < n; i++) {
			if (a[i] < a[mni]) {
				mni = i;
			}
		}

		console.log(n-1);
		for(let i = 1; i < n; i++) {
			if (i != mni) {
				console.log(mni+1, i+1, a[mni], a[mni] + i);
			}
		}
		console.log(mni+1, 1, a[mni] + mni, a[mni]);
	}
}

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

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

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

		let mni = 0;
		for (let i = 0; i < n; i++) {
			if (a[i] < a[mni]) {
				mni = i;
			}
		}

		console.log(n-1);
		for(let i = 1; i < n; i++) {
			if (i != mni) {
				console.log(mni+1, i+1, a[mni], a[mni] + i);
			}
		}
		console.log(mni+1, 1, a[mni], a[mni] + mni);
	}
}

"use strict";

var t = parseInt(readline(), 10);

for (; t > 0; --t) {
  var n = parseInt(readline(), 10);
  var arr = readline().split(" ").map(function (v) {
    return parseInt(v, 10);
  });

  if (n === 1) {
    print(0);
    continue;
  } // 找到最小值

  var minn = Math.min.apply(null, arr); // 找到最小值的（第一个）索引

  var mini = arr.indexOf(minn);
  var add = 0;
  var flag = true;
  print(n - 1);

  for (var i = 0; i < n; ++i) {
    if (i === mini && flag) {
      flag = false;
      continue;
    } else {
      ++add;
      print("".concat(mini + 1, " ").concat(i + 1, " ").concat(minn, " ").concat(minn + add));
    }
  }
}

"use strict";

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

  return gcd(b, a % b);
}

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

for (; t > 0; --t) {
  var n = parseInt(readline(), 10);
  var arr = readline().split(" ").map(function (v) {
    return parseInt(v, 10);
  });

  if (n === 1) {
    print(0);
    continue;
  } // 找到最小值

  var minn = Math.min.apply(null, arr); // 找到最小值索引

  var mini = arr.indexOf(minn); // 从最小值往两边扩散

  var ans = 0;
  var ope = []; // 左边

  for (var i = mini; i > 0; --i) {
    if (gcd(arr[i], arr[i - 1]) === 1) {
      continue;
    } else {
      while (gcd(arr[i], arr[i - 1]) !== 1) {
        ++arr[i - 1];
      }

      ++ans;
      ope.push("".concat(i, " ").concat(mini + 1, " ").concat(arr[i - 1], " ").concat(minn));
    }
  } // 右边

  for (var _i = mini; _i < n - 1; ++_i) {
    if (gcd(arr[_i], arr[_i + 1]) === 1) {
      continue;
    } else {
      while (gcd(arr[_i], arr[_i + 1]) !== 1) {
        ++arr[_i + 1];
      }

      ++ans;
      ope.push("".concat(mini + 1, " ").concat(_i + 2, " ").concat(minn, " ").concat(arr[_i + 1]));
    }
  }

  ret.push.apply(ret, [ans].concat(ope));
}

while (ret.length > 0) {
  print(ret.shift());
}

"use strict";

// import readlineSync from "readline-sync";
// const readline = readlineSync.question.bind(null, "input: ");
// const print = console.log;
// 上传时删去上面三行
// 最大公约数的函数
function gcd(a, b) {
  if (b === 0) {
    return a;
  }

  return gcd(b, a % b);
}

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

for (; t > 0; --t) {
  var n = parseInt(readline(), 10);
  var arr = readline()
    .split(" ")
    .map(function (v) {
      return parseInt(v, 10);
    });

  if (n === 1) {
    print(0);
    continue;
  }

  var ans = 0;
  var ope = [];

  for (var i = 0; i < n - 1; ++i) {
    if (gcd(arr[i], arr[i + 1]) === 1) {
      continue;
    } else {
      arr[i + 1] = arr[i] + 1;

      while (gcd(arr[i], arr[i + 1]) !== 1) {
        ++arr[i + 1];
      }

      ++ans;
      ope.push(
        ""
          .concat(i + 1, " ")
          .concat(i + 2, " ")
          .concat(arr[i], " ")
          .concat(arr[i + 1])
      );
    }
  }

  ret.push.apply(ret, [ans].concat(ope));
}

while (ret.length > 0) {
  print(ret.shift());
}


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

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

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

function main() {
	var integers = tokenizeIntegers(readline());
	var rowNum = integers[0], colNum = integers[1],
		clockwise = integers[2]%4, reflection = integers[3]%2,
		counterclockwise = integers[4]%4, pointNum = integers[5];

	var rotateFunctions = [
		function(point) {
			return point;
		},
		function(point) {
			return { r: point.c, c: point.rn+1-point.r,
					rn: point.cn, cn: point.rn };
		},
		function(point) {
			return { r: point.rn+1-point.r, c: point.cn+1-point.c,
					rn: point.rn, cn: point.cn };
		},
		function(point) {
			return { r: point.cn+1-point.c, c: point.r,
					rn: point.cn, cn: point.rn };
		}
	];
	var clockwiseFunction = rotateFunctions[clockwise],
		counterclockwiseFunction = rotateFunctions[(4-counterclockwise)%4];

	if (reflection == 0) {
		var reflectionFunction = rotateFunctions[0];
	}
	else {
		var reflectionFunction = function(point) {
			return { r: point.r, c: point.cn+1-point.c,
					rn: point.rn, cn: point.cn };
		}
	}

	for (var i = 0; i < pointNum; ++i) {
		var rc = tokenizeIntegers(readline());
		var point = { r: rc[0], c: rc[1], rn: rowNum, cn: colNum };
		point = clockwiseFunction(point);
		point = reflectionFunction(point);
		point = counterclockwiseFunction(point);
		print(point.r+" "+point.c);
	}
}

main();

print(function(n, m, x, y, z, p){
	x=x%4;
	y=y%2;
	z=z%4;
	function a(x, y, n, m){
		return [m-y, x, m, n];
	}
	function b(x, y, n, m){
		return [n-x, y, n, m];
	}
	function c(x, y, n, m){
		return [y, n-x, m, n];
	}

	function aa(xx,yy){
		var ans=[yy,xx,m+1,n+1];
		for(var ii=0; ii<x; ii++){
			ans=a.apply(0, ans);
		}
		for(var ii=0; ii<y; ii++){
			ans=b.apply(0, ans);
		}
		for(var ii=0; ii<z; ii++){
			ans=c.apply(0, ans);
		}
		return ans[1]+' '+ans[0];
	}
	var ans=[];
	for(var i=0; i<p; i++){
		ans.push(aa.apply( 0, readline().split(' ').map(Number) ));
	}

	return ans.join('\n');
}.apply(0, readline().split(' ').map(Number)));

var nmxyzp = readline().split(' ').map(Number);
var n = nmxyzp[0];
var m = nmxyzp[1];
var x = nmxyzp[2]%4;
var y = nmxyzp[3]%2;
var z = nmxyzp[4]%4;
var p = nmxyzp[5];
for (var i=0; i<p; i++) {
	var p1 = readline().split(' ').map(Number);
	var x1 = p1[0];
	var y1 = p1[1];
	var n1 = n;
	var m1 = m;
	for (var j=0; j<x; j++) {
		var x2 = y1;
		var y2 = n1 - x1 + 1;
		x1 = x2;
		y1 = y2;
		n1 = n1 + m1;
		m1 = n1 - m1;
		n1 = n1 - m1;
	}
	for (var j=0; j<y; j++) {
		y1 = m1 - y1 + 1;
	}
	for (var j=0; j<z; j++) {
		var x2 = m1 - y1 + 1;
		var y2 = x1;
		x1 = x2;
		y1 = y2;
		n1 = n1 + m1;
		m1 = n1 - m1;
		n1 = n1 - m1;
	}
	print(x1 + ' ' + y1);
}

print(function(n, m, x, y, z, p){
	x=x%4;
	y=y%2;
	z=z%4;
	function a(v){
		return [v[2]-v[1], v[0], v[3], v[2]];
	}
	function b(v){
		return [v[2]-v[0], v[1], v[2], v[3]];
	}
	function c(v){
		return [v[1], v[2]-v[0], v[3], v[2]];
	}
	function aa(i,j){
		var ans=[j,i,m+1,n+1];
		for(var ii=0; ii<x; ii++){
			ans=a(ans);
		}
		for(var ii=0; ii<y; ii++){
			ans=b(ans);
		}
		for(var ii=0; ii<z; ii++){
			ans=c(ans);
		}
		return ans[1]+' '+ans[0];
	}
	var ans=[];
	for(var i=0; i<p; i++){
		ans.push(aa.apply( 0, readline().split(' ').map(Number) ));
	}

	return ans.join('\n');
}.apply(0, readline().split(' ').map(Number)));

print(function(n, m, x, y, z, p){
	x=x%4;
	y=y%2;
	z=z%4;
	function a(v){
		return [v[3]-v[1], v[0], v[3], v[2]];
	}
	function b(v){
		return [v[0], v[2]-v[1], v[2], v[3]];
	}
	function c(v){
		return [v[1], v[2]-v[0], v[3], v[2]];
	}
	function aa(xx,yy){
		var ans=[xx,yy,n+1,m+1];
		for(var ii=0; ii<x; ii++){
			ans=a(ans);
		}
		for(var ii=0; ii<y; ii++){
			ans=b(ans);
		}
		for(var ii=0; ii<z; ii++){
			ans=c(ans);
		}
		return ans[0]+' '+ans[1];
	}
	var ans=[];
	for(var i=0; i<p; i++){
		ans.push(aa.apply( 0, readline().split(' ').map(Number) ));
	}

	return ans.join('\n');
}.apply(0, readline().split(' ').map(Number)));

print(function(n, m, x, y, z, p){
	x=x%4;
	y=y%2;
	z=z%4;
	function a(v){
		return [v[3]-v[1], v[0], v[3], v[2]];
	}
	function b(v){
		return [v[0], v[2]-v[1], v[2], v[3]];
	}
	function c(v){
		return [v[1], v[2]-v[0], v[3], v[2]];
	}
	function aa(xx,yy){
		var ans=[yy,xx,n+1,m+1];
		for(var ii=0; ii<x; ii++){
			ans=a(ans);
		}
		for(var ii=0; ii<y; ii++){
			ans=b(ans);
		}
		for(var ii=0; ii<z; ii++){
			ans=c(ans);
		}
		return ans[1]+' '+ans[0];
	}
	var ans=[];
	for(var i=0; i<p; i++){
		ans.push(aa.apply( 0, readline().split(' ').map(Number) ));
	}

	return ans.join('\n');
}.apply(0, readline().split(' ').map(Number)));

print(function(n, m, x, y, z, p){
	x=x%4;
	y=y%2;
	z=z%4;
	function a(v){
		return [v[2]-v[1], v[0], v[3], v[2]];
	}
	function b(v){
		return [v[2]-v[0], v[1], v[2], v[3]];
	}
	function c(v){
		return [v[1], v[2]-v[0], v[3], v[2]];
	}
	function aa(i,j){
		var ans=[j,i,n+1,m+1];
		for(var ii=0; ii<x; ii++){
			ans=a(ans);
		}
		for(var ii=0; ii<y; ii++){
			ans=b(ans);
		}
		for(var ii=0; ii<z; ii++){
			ans=c(ans);
		}
		return ans[1]+' '+ans[0];
	}
	var ans=[];
	for(var i=0; i<p; i++){
		ans.push(aa.apply( 0, readline().split(' ').map(Number) ));
	}

	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 tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var rowNum = integers[0], colNum = integers[1],
		clockwise = integers[2]%4, reflection = integers[3]%2,
		counterclockwise = integers[4]%4, pointNum = integers[5];
	print("clockwise = "+clockwise+", reflection = "+reflection+
			", counterclockwise = "+counterclockwise);

	var rotateFunctions = [
		function(point) {
			return point;
		},
		function(point) {
			return { r: point.c, c: point.rn+1-point.r,
					rn: point.cn, cn: point.rn };
		},
		function(point) {
			return { r: point.rn+1-point.r, c: point.cn+1-point.c,
					rn: point.rn, cn: point.cn };
		},
		function(point) {
			return { r: point.cn+1-point.c, c: point.r,
					rn: point.cn, cn: point.rn };
		}
	];
	var clockwiseFunction = rotateFunctions[clockwise],
		counterclockwiseFunction = rotateFunctions[(4-counterclockwise)%4];

	if (reflection == 0) {
		var reflectionFunction = rotateFunctions[0];
	}
	else {
		var reflectionFunction = function(point) {
			return { r: point.r, c: point.cn+1-point.c,
					rn: point.rn, cn: point.cn };
		}
	}

	for (var i = 0; i < pointNum; ++i) {
		var rc = tokenizeIntegers(readline());
		var point = { r: rc[0], c: rc[1], rn: rowNum, cn: colNum };
		point = clockwiseFunction(point);
		point = reflectionFunction(point);
		point = counterclockwiseFunction(point);
		print(point.r+" "+point.c);
	}
}

main();

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

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

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

function main() {
	var integers = tokenizeIntegers(readline());
	var rowNum = integers[0], colNum = integers[1],
		clockwise = integers[2]%4, reflection = integers[3]%2,
		counterclockwise = integers[4]%4, pointNum = integers[5];

	var rotateFunctions = [
		function(point) {
			return point;
		},
		function(point) {
			return { r: point.c, c: rowNum+1-point.r };
		},
		function(point) {
			return { r: rowNum+1-point.r, c: colNum+1-point.c };
		},
		function(point) {
			return { r: colNum+1-point.c, c: point.r };
		}
	];
	var clockwiseFunction = rotateFunctions[clockwise],
		counterclockwiseFunction = rotateFunctions[(4-counterclockwise)%4];

	if (reflection == 0) {
		var reflectionFunction = rotateFunctions[0];
	}
	else {
		var reflectionFunction = function(point) {
			return { r: point.r, c: colNum+1-point.c };
		}
	}

	for (var i = 0; i < pointNum; ++i) {
		var rc = tokenizeIntegers(readline());
		var point = { r: rc[0], c: rc[1] };
		point = clockwiseFunction(point);
		point = reflectionFunction(point);
		point = counterclockwiseFunction(point);
		print(point.r+" "+point.c);
	}
}

main();

var nmxyzp = readline().split(' ').map(Number);
var n = nmxyzp[0];
var m = nmxyzp[1];
var x = nmxyzp[2]%4;
var y = nmxyzp[3]%2;
var z = nmxyzp[4]%4;
var p = nmxyzp[5];
for (var i=0; i<p; i++) {
	var p1 = readline().split(' ').map(Number);
	var x1 = p1[1];
	var y1 = p1[0];
	var n1 = n;
	var m1 = m;
	for (var j=0; j<x; j++) {
		var x2 = n - y1 + 1;
		var y2 = x1;
		x1 = x2;
		y1 = y2;
		n1 = n1 + m1;
		m1 = n1 - m1;
		n1 = n1 - m1;
	}
	for (var j=0; j<y; j++) {
		x1 = m - x1 + 1;
	}
	for (var j=0; j<z; j++) {
		var x2 = y1;
		var y2 = m - x1 + 1;
		x1 = x2;
		y1 = y2;
		n1 = n1 + m1;
		m1 = n1 - m1;
		n1 = n1 - m1;
	}
	print(y1 + ' ' + x1);
}


var n = +readline()
  , as = readline().split(' ')

for ( var i in as ) as[i] = +as[i]
var topI = as.indexOf(n--)
  , upI = topI + 1
  , downI = topI - 1

while ( n ) {
  if ( downI >= 0 && as[downI] == n ) {
    downI--
    n--
  } else if ( upI < as.length && as[upI] == n ) {
    upI++
    n--
  } else break;
}

if ( !n ) print('YES')
else print('NO')

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};

var a = readLines();
var count = +a.shift();
var radiusArray = a.shift().split(" ").map(Number);

var max = radiusArray[0], iMax = 0;
for(var i = 0; i < count; i++)
	if ( max < radiusArray[i] ) {
		max = radiusArray[i];
		iMax = i;
	}

function check(ra, iMax) {
	var iLeft = iMax - 1;
	var iRight = iMax + 1;
	var max = ra[iMax];
	while(1) {
		var l = iLeft >= 0 ? ra[iLeft] : -1;
		var r = iRight < ra.length ? ra[iRight] : -1;
		if ( l === -1 && r === -1 ) return true;
		lrMax = Math.max(l, r);
		if ( max <= lrMax ) return false;
		max = lrMax;

		if ( l > r ) {
			iLeft--;
		} else {
			iRight++;
		}
	}
}

output( check(radiusArray, iMax) ? "YES" : "NO" );

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

var main = function() {
    var n = +rd();
    var A = rdAr();
    var max = Math.max(...A);
    A = [-Infinity].concat(A.concat([-Infinity]));
    var ind = A.indexOf(max);
    var top = max;
    for (var L = ind - 1, R = ind + 1; top !== -Infinity;) {
        var LVAL = A[L];
        var RVAL = A[R];
        var pos;
        if (LVAL > RVAL) {
            pos = L;
            --L;
        } else {
            pos = R;
            ++R;
        }
        var plate = A[pos];
        if (plate > top) {
            wr('NO'); return;
        }
        top = plate;
    }
    wr('YES');
};

if (INPUT) {
INPUT = INPUT.split('\n').reverse();
readline = () => INPUT.pop();
write = (s) => {OUTPUT += s};
print = (s) => {OUTPUT += s + '\n'};
}
const rd = readline;
const wr = write;
const pr = print;
const rdAr = () => rd().split(' ').map(v => +v);
const prAr = (a) => pr(a.join(' '));
const cmpLt = (a, b) => a - b;
const cmpGt = (a, b) => b - a;
Array.prototype.sortLt = function() { return this.sort(cmpLt); };
Array.prototype.sortGt = function() { return this.sort(cmpGt); };
const crAr = function(length, ...fillArgs) { return new Array(length).fill(...fillArgs); };
const getPrimes = function(n){var sieve=crAr(n+1,true);for(var i=2,j=4;j<sieve.length;j=Math.pow(++i,2)){if(sieve[j]){for(;j<sieve.length;j+=i){sieve[j]=false;}}}var primes=[];for(var i=2;i<sieve.length;++i){if(sieve[i]){primes.push(i);}}return primes;};

try {main();}finally{return OUTPUT;}
})();

n=+readline()
a=readline().split(' ').map(function(x){return +x-1})
b=new Array(n)
for (i=0;i<n;i++)
    b[a[i]]=i

l=b[n-1]
r=b[n-1]
for (i=n-2;i>=0;i--)
{
    if (b[i]+1==l)
        --l;
    else if (b[i]-1==r)
        ++r
    else
        break
}
if (r-l==n-1)
    print("yeS")
else
    print("NO")

var n = +readline()
  , as = readline().split(' ')
  , topI = as.indexOf(n--)

for ( var i in as ) as[i] = +as[i]

while ( n ) {
  var nextI = as.indexOf(n--)
  if ( Math.abs(nextI - topI) != 1) break;
  as.splice(nextI, 1)
  if ( nextI < topI ) topI--
}

if ( !n ) print('YES')
else print('NO')


//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 one = nextIntArray();
		var N = one[0];
		var K = one[1];
		var count = 0;
		var list = nextIntArray();
		var sum = 0;
		while(count < K){
			for(var j = 0; j < Math.floor(N / 2); j++){
				list.pop();
			}
			sum += list.pop();
			count++;
		}
		output[i] = sum;
	}
	myout(myconv(output, 9));
}

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 main() {
  let t = +readLine();
  while (t--) {
    const [len, numberOfArr] = readLine().split(" ").map(Number);
    const arr = readLine().split(" ").map(Number);
    let mid = Math.floor(len / 2);
    if (len % 2 === 0) {
      mid = mid - 1;
    }
    // console.log(`mid`, mid);
    let count = 0;
    let i = 0;
    if (mid === 0) i = len * numberOfArr - len;
    else i = len * numberOfArr - 1 - Math.floor(len / 2);
    let t = numberOfArr;
    while (t--) {
      // console.log(arr[i]);
      count += arr[i];
      if (mid === 0) i -= len;
      else i -= Math.floor(len / 2) + 1;
    }

    console.log(count);
  }
}

(()=>{"use strict";var t={675:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),Array.numbersMatrix=(t,e,r)=>{let n=[];null==t&&(e=t),null==r&&(r=0);for(let i=0;i<t;++i){let t=[];for(let n=0;n<e;++n)t.push(r);n.push(t)}return n},Array.prototype.sortAsc=function(){return this.sort(((t,e)=>t-e))},Array.prototype.sortDesc=function(){return this.sort(((t,e)=>e-t))},Array.prototype.max=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e<this.length;++e)t=Math.max(t,this[e]);return t},Array.prototype.min=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e<this.length;++e)t=Math.min(t,this[e]);return t},Array.prototype.sum=function(){let t=0;for(let e=0;e<this.length;++e)t+=this[e];return t},Array.prototype.modSum=function(t){let e=0;for(let r=0;r<this.length;++r)e+=this[r],e%=t;return e},Array.prototype.avg=function(){return this.sum()/this.length},Array.prototype.groupBy=function(t){let e=new Map;for(let r=0;r<this.length;++r){const n=t(this[r]);e.has(n)?e.get(n).push(this[r]):e.set(n,[this[r]])}return e},Array.prototype.deepCopy=function(){let t=[];if(0==this.length)return t;let e=!1;Array.isArray(this[0])&&(e=!0);for(let r=0;r<this.length;++r)e?t.push(this[r].deepCopy()):t.push(this[r]);return t},Array.prototype.transpose=function(){let t=[];if(0==this.length)return[[]];for(let e=0;e<this[0].length;++e){let r=[];for(let t=0;t<this.length;++t)r.push(this[t][e]);t.push(r)}return t},Array.prototype.toString=function(){if(0==this.length)return"";if(!Array.isArray(this[0]))return this.join(" ");let t="";for(let e=0;e<this.length;++e)t+=this[e].join(" "),e!=this.length-1&&(t+="\n");return t}},312:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(r(747));let o="",s=[],u=0,l="";const a="local"===process.argv[2],p=t=>{if(a){if(s=i.default.readFileSync("input.txt").toString().trim().split("\n").map((t=>t.trim())),t(),i.default.writeFileSync("output.txt",l),console.log(l),i.default.readFileSync("expected.txt").toString().trim()==l.trim()){const{exec:t}=r(129);t("osascript -e 'display notification \"✅ AC!!\"'")}}else process.stdin.resume(),process.stdin.setEncoding("utf-8"),process.stdin.on("data",(t=>{o+=t})),process.stdin.on("end",(e=>{s=o.trim().split("\n").map((t=>t.trim())),t(),console.log(l)}))};function h(){return s[u++]}function f(){return h().split(" ").map((t=>parseFloat(t)))}function c(){return h().split("")}e.default={runMain:p,runEachTest:t=>{p((()=>{let[e]=f();for(;e>0;)t(),e--}))},readline:h,nextNumbers:f,nextBigNumbers:function(){return h().split(" ").map((t=>BigInt(t)))},nextNumbersMatrix:function(t){let e=[];for(let r=0;r<t;++r)e.push(f());return e},nextCharacters:c,nextCharacterMatrix:function(t){let e=[];for(let r=0;r<t;++r)e.push(c());return e},nextIntervalArray:function(t){let e=[];for(let r=0;r<t;++r){const[t,r]=f();e.push({a:t,b:r})}return e},put:function(t){l+=t},puts:function(t){l+=t+"\n"},debug:function(t){a&&console.log(t)}}},965:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),r(675);const i=n(r(312));i.default.runEachTest((function(){let[t,e]=i.default.nextNumbers(),r=i.default.nextNumbers(),n=Math.ceil(t/2);i.default.debug(n);let o=0,s=(n-1)*e;for(let i=0;i<e;++i)o+=r[s],s+=t-n+1;i.default.puts(o)}))},129:t=>{t.exports=require("child_process")},747:t=>{t.exports=require("fs")}},e={};!function r(n){if(e[n])return e[n].exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(965)})();

// Solution written in typescript and compiled via webpack. Original source code below
// Happy Hacking 😜

// import './array'
//
// import io from './io'
//
// function main() {
//   let [n, k] = io.nextNumbers()
//   let a = io.nextNumbers()
//
//   let m = Math.ceil(n / 2)
//
//   io.debug(m)
//   // io.debug(a)
//
//   let s = 0
//
//   let i = (m - 1) * k
//
//   for (let j = 0; j < k; ++j) {
//     s += a[i]
//
//     i += n - m + 1
//   }
//
//   io.puts(s)
// }
//
// io.runEachTest(main)
// // io.runMain(main)

let input = ''

process.stdin.on('data', (x) => input += x)

process.stdin.on('end', () => {
  const lines = input.trim().split('\n')
  let curLine = 0
  const T = parseInt(lines[curLine++])
  for (let t = 0; t < T; t++) {
    const [n, k] = lines[curLine++].split(' ').map((x) => parseInt(x))
    const arr = lines[curLine++].split(' ').map((x) => parseInt(x)).sort((a, b) => a - b)

    const cLow = Math.floor((n - 1) / 2)
    let ans = 0n
    let curIdx = k * cLow
    for (let i = 0; i < k; i++) {
      ans += BigInt(arr[curIdx])
      curIdx += n - cLow
    }
    console.log(ans.toString())
  }
})

var sizeOfData = readline();
for (var dataI = 0; dataI < sizeOfData; dataI++) {
    var first = readline().split(" ");
    var n = first[0];
    var k = first[1];
    var arr = readline().split(" ");
    var sum = 0;
    var start = arr.length;
    for (var i = 0; i <  k; i++) {
        start = start - (Math.floor(n/2) + 1)
        sum += parseInt(arr[start]);
    }
    print(sum);
}


var n = parseInt(readline());
var numbers = readline().split(' ');

var sum = 0;
var min = Math.pow(10,9);
var count = 0;
var current;

for (var i = 0; i < n; i++) {
    current = parseInt(numbers[i]);
    if (numbers[i] % 2 == 0) sum += current
    else {
        sum += current;
        count++;
        min = Math.min(min, current);
    }
}

if (count % 2 == 1) sum -= min;

print(sum);

var n = parseInt(readline());
var integers = readline().split(' ').map(Number);
var ans = integers.reduce(function(l, r){
    return l + r;
});
var flag = ans;
for(var i = 0; i < integers.length; ++i){
    if(integers[i] & 1){
        flag = Math.min(flag, integers[i]);
    }
}
print(ans & 1 ? ans - flag : ans);

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

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

  let arr = d.split(' ').map(Number);
  arr.sort((a, b) => b - a);
  arr = arr.map(BigInt);

  let odd = 0;
  let lastOddIdx = 0;
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] % 2n === 1n) {
      odd++;
      lastOddIdx = i;
    }
  }

  let ans = arr.reduce((a, x) => a + x, 0n);

  if (odd % 2) {
    ans -= arr[lastOddIdx];
  }

  console.log(ans.toString());

  c++;
});

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

let input = []
process.stdin.on("data", function (chunk) {
    input += chunk
})

process.stdin.on("end", function () {
    const sentence = input.split('\n')
    const n = sentence[0]
    const integers = sentence[1].split(' ')
    let sum = 0
    let countOdd = 0
    let minOdd = Infinity
    for (let i = 0; i < integers.length; i++) {
        sum += parseInt(integers[i])
        if (parseInt(integers[i]) % 2 === 1) {
            countOdd += 1
            if (parseInt(integers[i]) < minOdd) {
                minOdd = parseInt(integers[i])
            }
        }

    }
    if (countOdd % 2 === 1) {
        sum -= minOdd
    }
    console.log(sum);
})

'use strict';

const n = parseInt(readline())
const integers = readline().split(' ').map(Number);

let even = integers.filter((x) => x % 2 === 0)
let odd = integers.filter((x) => x % 2 !== 0)
odd.sort((x,y) => y - x);

let odd_count = odd.length % 2 === 0 ? odd.length : odd.length - 1;
odd = odd.slice(0, odd_count);

let result = even.reduce((p, c) => p + c, 0)
result += odd.reduce((p, c) => p + c, 0);

print(result);

var n = Number(readline());
var str = readline().split(" ", n);
var num = new Array(n);
for (var i = 0; i < n; ++i) {
    num[i] = Number(str[i]);
}

var sum = 0;
var minOdd = 999999999;

for (var i = 0; i < n; ++i) {
    sum += num[i];
    if (num[i] % 2 === 1) {
        minOdd = Math.min(minOdd, num[i]);
    }
}

if (sum % 2 === 0) {
    print(sum);
} else {
    print(sum - minOdd);
}

/**
 * Created by ishanarora on 22/11/18.
 */

const stdin = process.openStdin();
let content = ``;
stdin.addListener('data', d => {
  content += d.toString();
});

stdin.addListener('end', () => {
 content =  content.split("\n");
content[0] = (parseInt(content[0]));
content[1] = content[1].split(" ");
content[1] = content[1].map(elem => parseInt(elem));

console.log(wetShark(content[0], content[1]))

});

function wetShark(count , elems) {

    let sum = 0;
    let deduct = Number.MAX_SAFE_INTEGER;
    for (var i = count - 1; i >= 0; i--) {
        sum += elems[i];
        if (elems[i] % 2 != 0) {
            deduct = Math.min(deduct, elems[i]);
        }
    }

    if (sum % 2 != 0) {
        sum -= deduct;
    }

    return sum;
}

var n = +readline(), a = readline().split(" ").map(Number);

var minOdd = 999999999;
var sum = 0;
for(var i = 0; i < n; ++i){
    sum += a[i];
    if(a[i]%2 == 1){
        minOdd = Math.min(minOdd, a[i]);
    }
}

if(sum%2 == 1){
    sum -= minOdd;
}

write(sum);

function main(n,arr) {

    all_sum = 0;
    smallest_odd = Infinity;

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

      all_sum += arr[i];
      if(arr[i] % 2 === 1)smallest_odd = Math.min(smallest_odd,arr[i]);
    }

    if(all_sum % 2 === 1){
      all_sum -= smallest_odd;
    }

    print(all_sum);

}

var n = parseInt(readline());
var arr = readline().split(" ");
for(var i = 0 ; i < arr.length ; i++)arr[i] = parseInt(arr[i]);

main(n,arr);

readline();
main.call(0, readNums());
function main(nums) {
    var sum = 0;
    var least = 2000000000;
    for (var i = 0; i < nums.length; i++) {
        var n = nums[i];
        sum += n;
        if ((n & 1) && n < least) {
            least = n;
        }
    }
    if (sum & 1) {
        sum -= least;
    }
    print(sum);
}
function readNums() {
    return readline().split(' ').map(function(v) {
        return v - 0;
    })
}
//function readline() {
//    return '999999999 999999999 999999999 999999999 999999999'
//}
//function print(v) {
//    console.log(v)
//}

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

var sum = 0;

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

var even_sum = sum;

if (sum % 2 == 1) {
	array.sort(function(a, b){return a - b;});
	var i = 0;
	while (array[i] % 2 < 1) {
		i++;
	}
	even_sum = sum - array[i];
}

print(even_sum);

var n = readline();
var a = readline().split(" ");
var sum = 0;
var odd = 0;
for (var i = 0; i < n; i++) {
	var t = parseInt(a[i]);
	sum += t;
	odd = (( (odd == 0)|| (t < odd) ) && (t&1)) ? t  : odd;
}
sum = ( !(sum&1) ) ? sum : sum - odd;
print(sum);

/**
 * Created by ishanarora on 22/11/18.
 */

const stdin = process.openStdin();
let content = ``;
stdin.addListener('data', d => {
  content += d.toString();
});

stdin.addListener('end', () => {
 content =  content.split("\n");
content[0] = (parseInt(content[0]));
content[1] = content[1].split(" ");
content[1] = content[1].map(elem => parseInt(elem));

console.log(wetShark(content[0], content[1]))

});

function wetShark(count , elems) {

    elems.sort();

    var prev = -1;
    var sum = 0;
    for (var i = count - 1; i >= 0; i--) {
        if (elems[i] % 2 === 0) {
            sum += elems[i];
        } else {
            if (prev === -1) {
                prev = elems[i];
            } else {
                sum += prev + elems[i];
                prev = -1;
            }
        }
    }
    return sum;
}

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

let input = []
process.stdin.on("data", function (chunk) {
    input += chunk
})

process.stdin.on("end", function () {
    const sentence = input.split('\n')
    const n = sentence[0]
    const integers = sentence[1].split(' ')
    let sum = 0
    let countOdd = 0
    let minOdd = Infinity
    for (let i = 0; i < integers.length; i++) {
        sum += parseInt(integers[i])
        if(parseInt(integers[i])  % 2 === 1) {
            countOdd += 1
        }
        if (parseInt(integers[i]) < minOdd) {
            minOdd = parseInt(integers[i])
        }
    }
    if (countOdd % 2 === 1) {
        sum -= minOdd
    }
    console.log(sum);
})

/**
 * Created by ishanarora on 22/11/18.
 */

const stdin = process.openStdin();
let content = ``;
stdin.addListener('data', d => {
  content += d.toString();
});

stdin.addListener('end', () => {
 content =  content.split("\n");
content[0] = (parseInt(content[0]));
content[1] = content[1].split(" ");
content[1] = content[1].map(elem => parseInt(elem));

console.log(wetShark(content[0], content[1]))

});

function wetShark(count , elems) {

    elems.sort();

    var prev = -1;
    var sum = 0;
    for (var i = count - 1; i >= 0; i--) {
        if(elems[i] < 0){
            continue;
        }
        if (elems[i] % 2 === 0) {
            sum += elems[i];
        } else {
            if (prev === -1) {
                prev = elems[i];
            } else {
                sum += prev + elems[i];
                prev = -1;
            }
        }
    }
    return sum;
}

var n = +readline(), a = readline().split(" ").map(Number);

var minOdd;
var sum = 0;
for(var i = 0; i < n; ++i){
    sum += a[i];
    if(minOdd == undefined && a[i]%2 == 1){
        minOdd = a[i];
    }
}

if(sum%2 == 1){
    sum -= minOdd;
}

write(sum);

var n = +readline(), a = readline().split(" ").map(Number).sort();

var minOdd;
var sum = 0;
for(var i = 0; i < n; ++i){
    sum += a[i];
    if(minOdd == undefined && a[i]%2 == 1){
        minOdd = a[i];
    }
}

if(sum%2 == 1){
    sum -= minOdd;
}

write(sum);

var n = +readline(), a = readline().split(" ").map(Number).sort(function(a, b){ return a < b; });

var minOdd;
var sum = 0;
for(var i = 0; i < n; ++i){
    sum += a[i];
    if(minOdd == undefined && a[i]%2 == 1){
        minOdd = a[i];
    }
}

if(sum%2 == 1){
    sum -= minOdd;
}

write(sum);

function main(n,arr) {

    var total = 0;
    var ans = 0;

    arr.sort();
    for(var i = 0 ; i < n ; i++){
      total += arr[i];

      total % 2 === 0 ? ans = total : ans = ans;
    }

    print(ans);

}

var n = parseInt(readline());
var arr = readline().split(" ");
for(var i = 0 ; i < arr.length ; i++)arr[i] = parseInt(arr[i]);

main(n,arr);

function main(n,arr) {

    var total = 0;
    var ans = 0;

    for(var i = 0 ; i < n ; i++){
      total += arr[i];

      total % 2 === 0 ? ans = total : ans = ans;
    }

    print(ans);

}

var n = parseInt(readline());
var arr = readline().split(" ");
for(var i = 0 ; i < arr.length ; i++)arr[i] = parseInt(arr[i]);

main(n,arr);

var n = readline();
var a = readline().split(" ");
var sum = 0;
var odd = 0;
for (var i = 0; i < n; i++) {
	var t = parseInt(a[i]);
	sum += t;
	odd = ( (odd == 0 && t&1 )|| (t < odd) ) ? t  : odd;
}
sum = ( !(sum&1) ) ? sum : sum - odd;
print(sum);

var n = parseInt(readline());
var integers = readline().split(' ').map(Number);
var ans = integers.reduce(function(l, r){
    return l + r;
});
var flag = ans;
for(var i = 0; i < integers.length; ++i){
    if(integers[i] & 1){
        flag = Math.min(flag, integers[i]);
        break;
    }
}
print(ans & 1 ? ans - flag : ans);

var n = parseInt(readline());
var integers = readline().split(' ').map(Number);
var ans = integers.reduce(function(l, r){
    return l + r;
});
integers = integers.sort();
for(var i = 0; i < integers.length; ++i){
    if(integers[i] & 1){
        ans -= integers[i];
        break;
    }
}
print(ans & 1 ? 0 : ans);

var n = parseInt(readline());
var numbers = readline().split(' ');

var evens = [];
var odds = [];

var sum = 0;

for (var i = 0; i < n; i++) {
    if (numbers[i] % 2 == 0) evens.push(parseInt(numbers[i]))
    else odds.push((parseInt(numbers[i])));
}

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

var isOddsEven = odds.length % 2 == 0 ? 0 : 1;

for (var i = 0; i < odds.length - isOddsEven; i++) {
    sum += odds[i];
}

print(sum);

var n = parseInt(readline());
var numbers = readline().split(' ');

var evens = [];
var odds = [];

var sum = 0;

for (var i = 0; i < numbers.length; i++) {
    if (numbers[i] % 2 == 0) evens.push(parseInt(numbers[i]))
    else odds.push((parseInt(numbers[i])));
}

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

var isOddsEven = odds.length % 2 == 0 ? 0 : 1;

for (var i = 0; i < odds.length - isOddsEven; i++) {
    sum += odds[i];
}

print(sum);


let response = [];
let solve = function(blocks) {
    let third = Math.floor(blocks / 3);

    if (blocks % 3 === 0) {
        return [third, third + 1, third - 1];
    } else if (blocks % 3 === 1) {
        return [third, third + 2, third - 1];
    } else {
        return [third + 1, third + 2, third - 1]
    }
}

var readline = require('readline');
var rl = readline.createInterface(process.stdin, process.stdout);

let tests = -2;
let test = 0;
rl.on('line', function(line) {
    if (tests < 0) {
        tests = parseInt(line);
    } else {
        response.push(solve(parseInt(line)));

        ++test;
        if (test === tests) {
            rl.close();
        }
    }

    // console.log(tests);
}).on('close',function(){
    response.forEach((list) => {
        list.forEach((item) => {
            process.stdout.write(item + " ");
        })
        process.stdout.write("\n");
    });

    process.exit(0);
});

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 iter = parseInt(readline());
  for (let i = 0; i < iter; i++) {
    let input = parseInt(readline());
    Build(input);
  }
}

function Build(n) {
  if (n % 3 == 0) {
    let comp = n / 3;
    print(`${comp} ${comp + 1} ${comp - 1}`);
  } else {
    let comp = Math.ceil(n / 3);
    let mul = 2 * comp;
    if (comp - (n - mul) > 1) print(`${comp - 1} ${comp + 1} ${n - mul}`);
    else print(`${comp} ${comp + 1} ${n - mul - 1}`);
  }
}

/// using js code
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

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

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

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

function main() {
    var t = parseInt(readline());
    while (t-- > 0) {
        var a = parseInt(readline());

        var x = parseInt((a+5)/3);
        var y = parseInt(x-1);
        var z = parseInt(a-x-y);
        if(z==0){
            y--;
            z++;
        }
        console.log(`${y} ${x} ${z}`);
    }
}

"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 = parseInt(readline());
       let a =  Math.floor(n/3);
       let b = Math.floor((n - a)/2);
       let c = n - a -b;
       if(b===c){
            b++;
            c--;
       }
       else{
           if(b<c) [b,c] = [c,b];
       }
       while((a<=b)||(b<=c)||(a<=c)){
            if(a<=b){
                 a++;
                 b--;
            }
            else if(a<=c){
                 a++;
                 c--;
            }
            else if(b<=c){
                 b++;
                 c--;
            }
       }
       console.log(`${b} ${a} ${c}`);
  }
};
solve();

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

function _main() {
	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;

	/**
	 * readNumber()        - int
	 * readArray()         - generic space separated array
	 * readBoolean()       - bool
	 * readChar()          - char
	 * readLine()          - string
	 * readNumberArray()   - numeric array
	 */

	const solve = () => {
	    let n = inputReader.readNumber();
	    let res = [3, 2, 1];
	    n -= 6;

	    let add = Math.floor(n / 3);
	    res[0] += add + (n % 3 >= 1);
	    res[1] += add + (n % 3 >= 2);
	    res[2] += add;

	    process.stdout.write(res[1] + ' ' + res[0] + ' ' + res[2] + '\n');
	};

	let tc = inputReader.readNumber();

	for(let t = 0; t < tc; ++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++]);
	}

	return {
		readNumber,
	}
}

/** Common Template Starts */

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 => string.trim());
    main();
});

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

/** Commnon Template Ends */

const solve = () => {
    let n = +(readLine());
    let res = [3, 2, 1];
    n -= 6;

    let add = Math.floor(n / 3);

    res[0] += add + (n % 3 >= 1);
    res[1] += add + (n % 3 >= 2);
    res[2] += add;

    process.stdout.write(res[1] + ' ' + res[0] + ' ' + res[2] + '\n');
};

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

    for(let t = 0; t < tc; ++t)
        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++];
}

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

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

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);

        let d = Math.floor(n/3);
        let r = n%3;

        if (r === 0) {
            output([d, (d+1), (d-1)].join(' '));
        } else if (r === 1) {
            output([d, (d+2), (d-1)].join(' '));
        } else if (r === 2) {
            output([(d+1), (d+2), (d-1)].join(' '));
        }
    }
}

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

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0 ; i < t; i++){
		let n = nl.num();
		let s = Math.floor(n/3);
		let x = n - s * 3;
		ans.push([s + Math.floor(x/2), s + 1 + Math.ceil(x/2), s-1]);

	}
	console.log(ans.map(e => e.join(' ')).join('\n'));
};

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

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

let getAnswer = (m) => {
  let ost = m%3;
  let v = (m - ost) / 3;
  if (ost === 0) {
    return [v, v+1, v-1];
  } else if (ost === 1) {
    return [v, v+2, v-1];
  } else {
    return [v+1, v+2, v-1];
  }
}

let sol = (input) => {
  let n = parseInt(input[0], 10);
  let mList = [];
  for (let i=1; i<=n; i++) {
    mList.push(parseInt(input[i], 10));
  }

  mList.forEach(m => console.log(getAnswer(m).join(' ')));

}

'use strict';

function solve(n) {
  const a = Math.ceil(n / 3) + 1,
        b = Math.floor((n - a) / 2) + 1,
        c = n - a - b;
  return `${b} ${a} ${c}`;
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const n = Number(await read());
      res.push(solve(n));
    }
    console.log(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', () => {
  inputs = str.split('\n').values();
  main(read);
});

//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 C = Math.floor(N / 3);
		if(N % 3 == 0){
			myout(C + " " + (C + 1) + " " + (C - 1));
		}else if(N % 3 == 1){
			myout(C + " " + (C + 2) + " " + (C - 1));
		}else{
			myout((C + 1) + " " + (C + 2) + " " + (C - 1));
		}
	}
}

const readline = require('readline')

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

function solve(n) {
    const r = n % 3
    const k = Math.floor(n / 3)
    if (!r) {
        return [k, k + 1, k - 1]
    } else if (r === 1) {
        return [k, k + 2, k - 1]
    } else if (r === 2) {
        return [k + 1, k + 2, k - 1]
    }
}

function solution(num) {
    fi = 3, se = 2, th = 1;
    many = parseInt((num - 6) / 3);
    rest = parseInt((num - 6) % 3);
    fi += many;
    se += many;
    th += many;
    while(rest > 0) {
        if(rest > 0) {
            fi++;
            rest--;
        }
        if(rest > 0) {
            se++;
            rest--;
        }
        if(rest > 0) {
            th++;
            rest--;
        }
    }
    print(se + " " + fi + " " + th);
}

n = readline()
for( k = 0; k < n ;k++) {
  num = readline();
  solution(num);
}

 var tests = parseInt(readline());
    var n;
    for (var t=0; t < tests; t++) {
        n = parseInt(readline());
        var h = Math.floor(n / 3);
        var ans = new Array(3).fill(h);
        var mod = n % 3;
        if (mod == 0) {
            ans[1]++;
            ans[2]--;
        } else if (mod == 1) {
            ans[1]+=2;
            ans[0]+=1;
            ans[2]-=2;
        } else if (mod == 2) {
            ans[1]+=2;
            ans[0]++;
            ans[2]--;
        }
        if (ans[2] == 0) {
            ans[0]--;
            ans[2]++;
        }
        print(ans.join(' '));
    }

var n = parseInt(readline());

while (n--) {
	var m = parseInt(readline());
	var div = parseInt(m / 3);
	var mod = parseInt(m % 3);
	var left = div + (mod - 1 >= 1);
	var mid = div + 1 + (mod >= 1);
	var right = div - 1;
	write(left + " " + mid + " " + right);
	print();
}

T = readline()
while (T--) {
   x = readline()
   a = Math.ceil(x/3)
   b = a+1
   c = x - (a+b)
   if(c ===0){
      a--
      c++
   }
   print(a,b,c)
}

"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 n = parseInt(readline());

        if (n % 3 === 0) {
            console.log(n/3, n/3+1, n/3-1);
        } else if (n % 3 === 1) {
            if ((n-1)/3 > 2) {
                console.log((n-1)/3+1, (n-1)/3+2, (n-1)/3-2);
            } else {
                console.log((n-1)/3, (n-1)/3+2, (n-1)/3-1);
            }
        } else {
            console.log((n-2)/3+1, (n-2)/3+2, (n-2)/3-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 t = parseInt(readline());

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

        if (n % 3 === 0) {
            console.log(n/3, n/3+1, n/3-1);
        } else if (n % 3 === 1) {
            if ((n-1)/3 > 2) {
                console.log((n-1)/3+1, (n-1)/3+2, (n-1)/3-2);
            } else {
                console.log((n-1)/3, (n-1)/3+2, (n-1)/3-1);
            }
        } else {
            if ((n-2)/3 > 2) {
                console.log((n-2)/3-1, (n-2)/3+2, (n-2)/3-2);
            } else {
                console.log((n-2)/3, (n-2)/3+1, (n-2)/3-2);
            }
        }
    }

}

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

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

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

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

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

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

        if (n % 3 === 0) {
            console.log(n/3, n/3+1, n/3-1);
        } else if (n % 3 === 1) {
            if ((n-1)/3 > 2) {
                console.log((n-1)/3+1, (n-1)/3+2, (n-1)/3-2);
            } else {
                console.log((n-1)/3, (n-1)/3+2, (n-1)/3-1);
            }
        } else {
            if ((n+1)/3 > 2) {
                console.log((n+1)/3-1, (n+1)/3+2, (n+1)/3-2);
            } else {
                console.log((n+1)/3, (n+1)/3+1, (n+1)/3-2);
            }
        }
    }

}

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

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

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

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

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

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

        if (n % 3 === 0) {
            console.log(n/3 + ' ' +  n/3+1 + ' ' + n/3-1);
        } else if (n % 3 === 1) {
            if ((n-1)/3 > 2) {
                console.log((n-1)/3+1 + ' ' + (n-1)/3+2 + ' ' + (n-1)/3-2);
            } else {
                console.log((n-1)/3 + ' ' + (n-1)/3+2 + ' ' + (n-1)/3-1);
            }
        } else {
            if ((n+1)/3 > 2) {
                console.log((n+1)/3-1 + ' ' + (n+1)/3+2 + ' ' + (n+1)/3-2);
            } else {
                console.log((n+1)/3 + ' ' + (n+1)/3+1 + ' ' + (n+1)/3-2);
            }
        }
    }

}

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

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

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

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

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

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

        if (n % 3 === 0) {
            console.log(n/3 + ' ' +  n/3+1 + ' ' + n/3-1);
        } else if (n % 3 === 1) {
            if ((n-1)/3 > 2) {
                console.log((n-1)/3+1 + ' ' + (n-1)/3+2 + ' ' + (n-1)/3-2);
            } else {
                console.log((n-1)/3 + ' ' + (n-1)/3+2 + ' ' + (n-1)/3-1);
            }
        } else {
            if ((n+1)/3 > 2) {
                console.log((n+1)/3-1 + ' ' + (n+1)/3+2 + ' ' + (n+1)/3-2);
            } else {
                console.log((n+1)/3 + ' ' + (n+1)/3+1 + ' ' + (n+1)/3-2);
            }
        }
    }

}

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

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

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

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

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

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

        if (n % 3 === 0) {
            console.log(n/3, n/3+1, n/3-1);
        } else if (n % 3 === 1) {
            if ((n-1)/3 > 2) {
                console.log((n-1)/3+1, (n-1)/3+2, (n-1)/3-2);
            } else {
                console.log((n-1)/3, (n-1)/3+2, (n-1)/3-1);
            }
        } else {
            if ((n+1)/3 > 2) {
                console.log((n+1)/3-1, (n+1)/3+2, (n+1)/3-2);
            } else {
                console.log((n+1)/3, (n+1)/3+1, (n+1)/3-2);
            }
        }
    }

}

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 iter = parseInt(readline());
  for (let i = 0; i < iter; i++) {
    let input = parseInt(readline());
    Build(input);
  }
}

function Build(n) {
  if (n % 3 === 0) {
    let comp = n / 3;
    print(`${comp} ${comp + 1} ${comp - 1}`);
  } else {
    let comp = Math.ceil(n / 3);
    if (comp - (n - 2 * comp) > 1) print(`${comp - 1} ${comp + 1} ${n - (2 * comp)}`);
    else print(`${comp} ${comp + 1} ${n - (2 * comp) - 1}`);
  }
}

Build(8);

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 iter = parseInt(readline());
  for (let i = 0; i < iter; i++) {
    let input = parseInt(readline());
    Build(input);
  }
}

function Build(n) {
  if (n % 3 === 0) {
    let comp = n / 3;
    print(`${comp} ${comp + 1} ${comp - 1}`);
  } else {
    let comp = Math.ceil(n / 3);
    print(`${comp - 1} ${comp + 1} ${n - (2 * comp)}`);
  }
}

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 iter = parseInt(readline());
  for (let i = 0; i < iter; i++) {
    let input = parseInt(readline());
    Build(input);
  }
}

function Build(n) {
  if (n % 3 == 0) {
    let comp = n / 3;
    print(`${comp} ${comp + 1} ${comp - 1}`);
  } else {
    let comp = Math.ceil(n / 3);
    print(`${comp} ${comp + 1} ${comp - 2}`);
  }
}

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 iter = parseInt(readline());
  for (let i = 0; i < iter; i++) {
    let input = parseInt(readline());
    Build(input);
  }
}

function Build(n) {
  if (n % 3 === 0) {
    let comp = n / 3;
    print(`${comp} ${comp + 2} ${comp - 1}`);
  } else {
    let comp = Math.ceil(n / 3);
    print(`${comp} ${comp + 2} ${comp - 2}`);
  }
}

/// using js code
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

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

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

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

function main() {
    var t = parseInt(readline());
    while (t-- > 0) {
        var a = parseInt(readline());

        var x = parseInt((a+5)/3);
        var y = parseInt(x-1);
        var z = parseInt(a-x-y);
        if(z==0){
            y--;
            z++;
        }
        console.log(`${x} ${y} ${z}`);
    }
}

let response = [];
let solve = function(blocks) {
    let third = Math.floor(blocks / 3);

    if (blocks % 3 === 0) {
        return [third, third + 1, third - 1];
    } else if (blocks % 3 === 1) {
        return [third, third + 2, third - 1];
    } else {
        return [third + 1, third + 2, third - 1]
    }
}

var readline = require('readline');
var rl = readline.createInterface(process.stdin, process.stdout);

let tests = -2;
let test = 0;
rl.on('line', function(line) {
    if (tests < 0) {
        tests = parseInt(line);
    } else {
        response.push(solve(parseInt(line)));

        ++test;
        if (test === tests) {
            rl.close();
        }
    }

    // console.log(tests);
}).on('close',function(){
    response.forEach((list) => {
        list.forEach((item) => {
            rl.write(item + " ");
        })
        rl.write("\n");
    });

    process.exit(0);
});

let response = [];
let solve = function(blocks) {
    let third = Math.floor(blocks / 3);

    if (blocks % 3 === 0) {
        return [third, third + 1, third - 1];
    } else if (blocks % 3 === 1) {
        return [third, third + 2, third - 1];
    } else {
        return [third + 1, third + 2, third - 1]
    }
}

var readline = require('readline');
var rl = readline.createInterface(process.stdin, process.stdout);

let tests = -2;
let test = 0;
rl.on('line', function(line) {
    if (tests < 0) {
        tests = parseInt(line);
    } else {
        response.push(solve(parseInt(line)));

        ++test;
        if (test === tests) {
            rl.close();
        }
    }

    // console.log(tests);
}).on('close',function(){
    response.forEach((list) => {
        list.forEach((item) => {
            rl.write(item + " ");
        })
        rl.write("\n");
    });
});

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

const solve = () => {
  const gcd = (a, b) => (a % b === 0 ? b : gcd(b, a % b));
  let t = parseInt(readline());
  while (t--) {
       let n = parseInt(readline());
       let a = n%2===0 ? Math.floor(n/2) : Math.ceil(n/2);
       let b = n - a - 1;
       console.log(`${b} ${a} ${n-(a+b)}`);
  }
};
solve();

function solution(num) {
    fi = 3, se = 2, th = 1;
    many = (num - 6) / 3;
    rest = (num - 6) % 3;
    fi += many;
    se += many;
    th += many;
    while(rest > 0) {
        if(rest > 0) {
            fi++;
            rest--;
        }
        if(rest > 0) {
            se++;
            rest--;
        }
        if(rest > 0) {
            th++;
            rest--;
        }
    }
    print(se + " " + fi + " " + th);
}

n = readline()
for( k = 0; k < n ;k++) {
  num = readline();
  solution(num);
}

function solution(num) {
    fi = 3, se = 2, th = 1;
    many = (num - 6) / 3;
    rest = (num - 6) % 3;
    fi += many;
    se += many;
    th += many;
    while(rest > 0) {
        if(rest > 0) {
            fi++;
            rest--;
        }
        if(rest > 0) {
            se++;
            rest--;
        }
        if(rest > 0) {
            th++;
            rest--;
        }
    }
    console.log(se + " " + fi + " " + th);
}

n = readline()
for( k = 0; k < n ;k++) {
  num = readline();
  print(num);
}