readline();
var arr = readline().split(' ');
arr = arr.map(elem => {
    return parseInt(elem, 10);
});
var res = 1;
var max = 0;
for (var i = 0; i < arr.length - 1; i++) {
    if (arr[i+1] <= arr[i]) {
        if (res > max) {
            max = res;
        }
        res = 1;
    } else {
        res++;
    }
}
if (res > max) {
    max = res;
}
print(max);

var n = readline();

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

var b = [];

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

var cur = 1;
var ans = 1;

for (var i = 1; i < a.length; i++) {
    a[i] = Number(a[i]);
    if (a[i] > a[i - 1]) {
        cur = cur + 1;
    }
    else {
        cur = 1;
    }
    ans = Math.max(cur, ans);
}

print(ans);

//var array = readline().split(" ").map(item => +item);
readline();
var line = readline().split(" ").map(item => +item);
var max = 1;

if(line.length > 1) {
    var prev = line[0],
    count = 1;

    for(var i = 1; i < line.length; i++) {
        if (prev < line[i]) {
            count++;
            max = Math.max(max, count);
        } else {
            count = 1;
        }
        prev = line[i];
    }
    print(max);
} else {
    print(1);
}

//print((i - 1).toString());

'use strict';

// const rlLib = require('readline');

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

// let inputs = [];
// let allCount = 2;
// let currentLine = 0;

// rl.on('line', (input) => {
//  inputs.push(input);
//  if (inputs.length >= allCount) {
//      main();

//      rl.close();
//  }
// });

// function readline() {
//  return inputs[currentLine++];
// }
// function print() {
//  console.log.apply(this, arguments);
// }

// // function main() {
// //     let count = +readline();
// //     let arr = readline().split(' ').map(function(e) {return parseInt(e, 10);});
// //     print(func(arr));
// // }

// /**
//  * @param {number} s
//  * @param {number[]} nums
//  * @return {number}
//  */
//  function main() {
    readline();
    let arr = readline().split(' ').map(function(e) {return parseInt(e, 10);});
    let res = 0;

    for (var i = 1, count = 1; i < arr.length; i++) {
        if (arr[i] <= arr[i - 1]) {
            if (res < count) {
                res = count;
            }
            count = 1;
        } else {
            count++;
        }
    }

    print(count > res ? count : res);
// };

function main() {
    readline();
    var data = readline().split(' ').map(Number);
    var res = 1;
    var current = 1;
    for(var i=1;i<data.length;i++){
        if(data[i]>data[i-1]){
            current++;
        } else {
            current = 1;
        }
        if(current>res){
            res = current;
        }
    }
    print(res)
}

main()

'use strict';

function findMax(n, arr) {
    let maxLen = 1;
    let currentLen = 1;

    for (let i=1; i<n; i++) {
        if (arr[i] > arr[i-1]) {
            currentLen++;
            if (currentLen > maxLen) {
                maxLen = currentLen;
            }
        } else {
            currentLen = 1;
        }
    }
    return maxLen;
}

print(findMax(parseInt(readline()), readline().split(' ').map(x=>parseInt(x))));

//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');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
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 N = nextInt();
  var list = nextIntArray();
  var output = 1;
  var count = 1;
  for(var i = 1; i < N; i++){
    if(list[i - 1] < list[i]){
      count++;
    }else{
      output = Math.max(count, output);
      count = 1;
    }
  }
  output = Math.max(count, output);
  myout(output);
}

var stdin = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function(data) {
  stdin += data;
});
process.stdin.on("end", function() {
  main(stdin);
});

// const stdin = `5
// 1 7 2 11 15`;
// main(stdin);

/////////////// ignore above this line ////////////////////

function main(stdin) {
  const sequence = readLine(stdin, 1);
  const sequenceArray = sequence.split(" ").map(n => Number(n));
  let arrays = [];
  let i = 1;
  let prev = 0;
  while (sequenceArray[i]) {
    const curr = sequenceArray[i - 1];
    const next = sequenceArray[i];

    if (curr >= next) {
      arrays.push(sequenceArray.slice(prev, i));
      prev = i;
    }

    i++;

    if (!sequenceArray[i]) {
      arrays.push(sequenceArray.slice(prev, i));
    }
  }

  // console.log(arrays);
  console.log(
    arrays.reduce((acc, el) => {
      return el.length > acc ? el.length : acc;
    }, 1)
  );
}

function readLine(str, line) {
  return str.split(/\r?\n/).filter(s => Boolean(s.trim()))[line];
}

//var n = 3;
var n = parseInt(readline());
//var a = [1, 2, 3];
var a = readline().split(" ").map(function(x) { return parseInt(x); });

if (n == 1) {
    write("1");
}
else
{
    var t = 1;
    var max = -1;

    for (var i = 1; i< n; ++i) {
        if (a[i - 1] < a[i]) {
            ++t;
        } else {
            if (t > max) {
                max = t;
            }
            t = 1;
        }
    }

    if (t > max) {
        max = t;
    }

    write(max);
}

//function write(n) {
//    console.log(n);
//}

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

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

  const arr = d.split(' ').map(Number);
  let best = 1;
  let curr = 1;
  let v = arr[0];

  for (let i = 1; i < arr.length; i++) {
    if (arr[i] > v) {
      curr++;
    }
    else {
      curr = 1;
    }

    best = Math.max(curr, best);
    v = arr[i];
  }

  console.log(best);

  c++;
});

rl.on('close', () => {

});

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

let switcher = false;

rl.on('line', function(line){
    if (switcher) {
        let arr = line.split(' ').map(el => +el);
        console.log(findMaxLength(arr));
    }
    switcher = !switcher;
});

const findMaxLength = arr => {
    let maxLength = 1;
    let tmpMax = 1;
    for (let i = 1; i < arr.length; i++) {
        if (arr[i - 1] < arr[i]) {
            tmpMax++;
        } else {
            if (tmpMax > maxLength) maxLength = tmpMax;
            tmpMax = 1;
        }
    }
    if (tmpMax > maxLength) maxLength = tmpMax;
    return maxLength;
}

var n = readline();
var a = readline().split(' ');

for (var i = 0; i < a.length; i++) {
	a[i] = Number(a[i])
}
var count = 1;

var ans = 1;
for (var i = 0; i < a.length - 1; i++) {
	if (a[i] < a[i + 1]) {
		count++;
	} else {
		count = 1;
	}
	ans = Math.max(ans, count);
}

print(ans);
// console.log(ans)

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

let lineNum = 0;

rl.on('line', (l) => {
  lineNum++
  if (lineNum === 1) {
    return
  }
  arr = l.split(" ").map(x => parseInt(x));
  // console.log(arr);
  let maxlen = 0;
  let x = 0;
  while (x < arr.length) {
    templen = 1;
    let y = x+1;
    while(y < arr.length && arr[y] > arr[y-1]) {
      templen++
      y++
    }
    if (templen > maxlen) {
      maxlen = templen
    }
    x = y;
  }
  console.log(maxlen)
  rl.close();
})

var n = readline();
var a = readline().split(' ');

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

var count = 1;

var len = []
var count = 1

for (var i = 0; i < a.length; i++) {
	if (a[i] < a[i + 1]) {
		count++
	} else {
		len.push(count)
		count = 1
	}
}

len.sort().reverse()

print(len[0])
// console.log(ans)

var n = +readline();
var a = readline().split(' ').map(Number);
var max = 0, cnt = 1;
for (var i = 1; i < n; i++) {
    if (a[i - 1] < a[i]) {
        cnt += 1
    } else {
        max = Math.max(max, cnt);
        cnt = 1
    }
}
print(Math.max(max, cnt));

var stdin = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function(data) {
  stdin += data;
});
process.stdin.on("end", function() {
  main(stdin);
});

// const stdin = `3
// 1 7 2 11 15`;
// main(stdin);

/////////////// ignore above this line ////////////////////

function main(stdin) {
  const sequence = readLine(stdin, 1);
  const sequenceArray = sequence.split(" ").map(n => Number(n));
  let maxSeq = 0;
  let currSeq = 1;
  let i = 1;
  while (sequenceArray[i]) {
    const curr = sequenceArray[i - 1];
    const next = sequenceArray[i];

    if (curr < next) {
      currSeq++;
    }

    maxSeq = maxSeq < currSeq ? currSeq : maxSeq;

    if (curr > next) {
      currSeq = 1;
    }

    i++;
  }

  console.log(maxSeq);
}

function readLine(str, line) {
  return str.split(/\r?\n/).filter(s => Boolean(s.trim()))[line];
}

var stdin = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function(data) {
  stdin += data;
});
process.stdin.on("end", function() {
  main(stdin);
});

// const stdin = `5
// 1 7 2 11 15`;
// main(stdin);

/////////////// ignore above this line ////////////////////

function main(stdin) {
  const sequence = readLine(stdin, 1);
  const sequenceArray = sequence.split(" ").map(n => Number(n));
  let arrays = [];
  let i = 1;
  let prev = 0;
  while (sequenceArray[i]) {
    const curr = sequenceArray[i - 1];
    const next = sequenceArray[i];

    if (curr >= next) {
      arrays.push(sequenceArray.slice(prev, i));
      prev = i;
    }

    i++;

    if (!sequenceArray[i]) {
      arrays.push(sequenceArray.slice(prev, i));
    }
  }

  // console.log(arrays);
  console.log(
    arrays.reduce((acc, el) => {
      return el.length > acc ? el.length : acc;
    }, 0)
  );
}

function readLine(str, line) {
  return str.split(/\r?\n/).filter(s => Boolean(s.trim()))[line];
}

var stdin = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function(data) {
  stdin += data;
});
process.stdin.on("end", function() {
  main(stdin);
});

// const stdin = `5
// 1 7 2 11 15`;
// main(stdin);

/////////////// ignore above this line ////////////////////

function main(stdin) {
  const sequence = readLine(stdin, 1);
  const sequenceArray = sequence.split(" ").map(n => Number(n));
  let arrays = [];
  let i = 1;
  let prev = 0;
  while (sequenceArray[i]) {
    const curr = sequenceArray[i - 1];
    const next = sequenceArray[i];

    if (curr >= next) {
      arrays.push(sequenceArray.slice(prev, i));
      prev = i;
    }

    i++;

    if (!sequenceArray[i]) {
      arrays.push(sequenceArray.slice(prev, i));
    }
  }

  console.log(arrays);
  console.log(
    arrays.reduce((acc, el) => {
      return el.length > acc ? el.length : acc;
    }, 0)
  );
}

function readLine(str, line) {
  return str.split(/\r?\n/).filter(s => Boolean(s.trim()))[line];
}

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

rl.on('line', function(line){
    if (line.length > 1) {
        let arr = line.split(' ');
        console.log(findMaxLength(arr));
    }
})

const findMaxLength = arr => {
    let maxLength = 1;
    let tmpMax = 1;
    for (let i = 1; i < arr.length; i++) {
        if (arr[i - 1] < arr[i]) {
            tmpMax++;
        } else {
            if (tmpMax > maxLength) maxLength = tmpMax;
            tmpMax = 1;
        }
    }
    if (tmpMax > maxLength) maxLength = tmpMax;
    return maxLength;
}

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

rl.on('line', function(line){
    if (line.length > 1) {
        let arr = line.split(' ').map(el => +el);
        console.log(findMaxLength(arr));
    }
})

const findMaxLength = arr => {
    let maxLength = 1;
    let tmpMax = 1;
    for (let i = 1; i < arr.length; i++) {
        if (arr[i - 1] < arr[i]) {
            tmpMax++;
        } else {
            if (tmpMax > maxLength) maxLength = tmpMax;
            tmpMax = 1;
        }
    }
    if (tmpMax > maxLength) maxLength = tmpMax;
    return maxLength;
}

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

rl.on('line', (l) => {
  arr = l.split(" ").map(x => parseInt(x));
  // console.log(arr);
  let maxlen = 0;
  let x = 0;
  while (x < arr.length - 1) {
    templen = 1;
    let y = x+1;
    while(y < arr.length && arr[y] > arr[y-1]) {
      templen++
      y++
    }
    if (templen > maxlen) {
      maxlen = templen
    }
    x = y;
  }
  console.log(maxlen)
  rl.close();
})

readline();
var arr = readline().split(' ');
arr = arr.map(elem => {
    return parseInt(elem);
});
var res = 1;
var max = 0;
for (var i = 0; i < arr.length - 1; i++) {
    if (arr[i+1] <= arr[i]) {
        if (res > max) {
            max = res;
            res = 1;
        }
    } else {
        res++;
    }
}
print(max);

readline();
var arr = readline().split(' ');
arr = arr.map(elem => {
    return parseInt(elem);
});
var res = 1;
var max = 1;
for (var i = 0; i < arr.length - 1; i++) {
    if (arr[i+1] <= arr[i]) {
        if (res > max) {
            max = res;
            res = 1;
        }
    } else {
        res++;
    }
}
if (res > max) {
    max = res;
}
print(max);

readline();
var arr = readline().split(' ');
arr = arr.map(elem => {
    return parseInt(elem);
});
var res = 1;
var max = 0;
for (var i = 0; i < arr.length - 1; i++) {
    if (arr[i+1] <= arr[i]) {
        if (res > max) {
            max = res;
            res = 1;
        }
    } else {
        res++;
    }
}
if (res > max) {
    max = res;
}
print(max);

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

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

var cur = 1;
var ans = 1;

for (var i = 1; i < a.length; i++) {
    a[i] = Number(a[i]);
    if (a[i] > a[i - 1]) {
        cur = cur + 1;
    }
    else {
        cur = 1;
    }
    ans = Math.max(cur, ans);
}

print(ans);

//var array = readline().split(" ").map(item => +item);
readline();
var line = readline().split(" ").map(item => +item);
var max = 1;

if(line.length > 1) {
    var prev = line[0],
    count = 1;

    for(var i = 1; i < line.length; i++) {
        if (prev < line[i]) {
            count++;
            max = Math.max(max, count);
            prev = line[i];
        } else {
            count = 1;
        }
    }
    print(max);
} else {
    print(1);
}

//print((i - 1).toString());

//var n = 5
var n = parseInt(readline());
//var a = [100, 100, 100, 100, 100];
var a = readline().split(" ").map(function(x) { return parseInt(x); });

var max = -1;

if (n == 1) {
    write("1");
} else {
    var t = 0;

    for (var i = 1; i< n; ++i) {
        if (a[i - 1] < a[i]) {
            ++t;
        } else {
            if (t > max) {
                max = t;
            }
            t = 1;
        }
    }

    if (t > max) {
        max = t;
    }

    //console.log("r: " + max);
    write(max);
}

var n = readline()
var a = readline().split(' ')

var len = []
var count = 1

for (var i = 0; i < a.length; i++) {
	if (a[i] < a[i + 1]) {
		count++
	} else {
		len.push(count)
		count = 1
	}
}

len.sort().reverse()

print(len[0])

var n = readline();
var a = readline().split(' ');
var count = 1;

var ans = 1;
for (var i = 0; i < a.length - 1; i++) {
	if (a[i] < a[i + 1]) {
		count++;
	} else {
		count = 1;
	}
	ans = Math.max(ans, count);
}

print(ans);

var n = readline()
var a = readline().split(' ')

var a = [1, 7, 2, 11, 15]

var len = []
var count = 1

for (var i = 0; i < a.length - 1; i++) {
	if (a[i] < a[i + 1]) {
		count++
	} else {
		len.push(count)
		count = 1
	}
}

len.sort().reverse()

print(len[0])

var n = readline()
var a = readline().split(' ');

var len = [];
var count = 1;

for (var i = 0; i < a.length; i++) {
	if (a[i] < a[i + 1]) {
		count++;
	} else {
		len.push(count)
		count = 1;
	}
}

len.sort().reverse();
print(len[0]);

var n = readline()
var a = readline().split(' ')

var len = []
var count = 1

for (var i = 0; i < a.length - 1; i++) {
	if (a[i] < a[i + 1]) {
		count++
	} else {
		len.push(count)
		count = 1
	}
}

len.sort().reverse()

print(len[0])

var n = readline()
var a = readline().split(' ')

var count = 1

var ans = 1
for (var i = 0; i < a.length - 1; i++) {
	if (a[i] < a[i + 1]) {
		count++
	} else {
		count = 1
	}
	ans = Math.max(ans, count);
}

print(ans)


const lines = [];
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.on('line', line => lines.push(line));
rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

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

/*---------------------------------------------------*/

function div(val, by){
    return (val - val % by) / by;
}

const getDigits = (x) => {
    let digits = new Array(10).fill(false);
    let len = 0;
    while (x) {
        len++;
        digits[x % 10n] = true;
        x /= 10n;
    }
    return [digits, len];
}

const getLen = (x) => {
    let str = x.toString(10);
    return str.length;
}

const calc = (t)=>{
    /* read */
    let n = readline();
    let a = ra();

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

    for (let i = 0; i < n; i++) {
        if ((sum - a[i]) / (n - 1) === a[i]) return 'YES';
    }

    return 'NO';
};

function main() {
    let T = +readline();
    let out = [];
    for (let t = 1; t <= T; t++){
        out.push(calc(t));
        // process.stdout.write(`${calc(t)}\n`);
    }
    process.stdout.write(out.join('\n')+'\n');
}

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var total = 0;
            var flag = false;
            for(j = 0; j < n; j++){
                total += k[j];
            }
            for(j = 0; j < n; j++){
                var a = (total - k[j]) / (n - 1);
                if(k[j] == a){
                    flag = true;
                    break;
                }
            }
            console.log(flag ? 'YES' : 'NO');
        }
    }
});

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
	var t = lines[0];
	var n = 0;
	for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var sum = 0;
            var b = false;
            for(j = 0; j < n; j++){
                sum += k[j];
            }
            for(j = 0; j < n; j++){
                var v1 = k[j];
                var v2 = ((sum - k[j]) / (n - 1));
                if(v1 == v2){
                    b = true;
                    break;
                }
            }
            console.log(b ? 'YES' : 'NO');
        }
    }
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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 arr = readline().split(' ').map(Number);

        let sum = arr.reduce((a, b) => a + b, 0);
        let res = 'NO';

        for (let i = 0; i < n; i++) {
            if ((sum - arr[i]) / (n - 1) === arr[i]) {
                res = 'YES';
                break;
            }
        }

        output(res);
    }
}

'use strict';
const readline = require('readline');
const util = require('util');
const lineReader = readline.createInterface({
    input: process.stdin,
});
let inputPos = 0;
const inputWords = [];
lineReader.on('line', (line) => {
    inputWords.push.apply(inputWords, line.split(' ').filter(s => s != ''));
});
lineReader.on('close', main);
function check(b) {
    if (!b) {
        process.stderr.write(`${new Error().stack}\n`);
        process.exit(-1);
    }
}
function printf(...args) {
    process.stdout.write(util.format(...args));
}
function nextInt() {
    return Math.trunc(Number(inputWords[inputPos++]));
}
function nextStr() {
    return inputWords[inputPos++];
}
function af(l) {
    return Array.from({ length: l });
}
function lowerBound(a, x) {
    let lo = 0;
    let hi = a.length;
    while (lo < hi) {
        let mid = lo + Math.trunc((hi - lo) / 2);
        if (a[mid] >= x) {
            hi = mid;
        }
        else {
            lo = mid + 1;
        }
    }
    return hi;
}
const INIT = -1;
const INF = Infinity;
let n;
let a;
function solve() {
    let sum = 0;
    for (let i = 0; i < n; i++) {
        sum += a[i];
    }
    for (let i = 0; i < n; i++) {
        let tot = sum - a[i];
        if (a[i] * (n - 1) == tot) {
            return true;
        }
    }
    return false;
}
function main() {
    let tc = nextInt();
    while (tc-- > 0) {
        n = nextInt();
        a = af(n);
        for (let i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        if (solve()) {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var list = nextIntArray(N);
		var sum = 0;
		for(var i = 0; i < N; i++){
			sum += list[i];
		}
		var ok = false;
		for(var i = 0; i < N; i++){
			if((sum - list[i]) / (N - 1) == list[i]){
				ok = true;
				break;
			}
		}
		myout((ok) ? "Yes" : "No");
	}
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	// console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else 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;}}

function Main(){
    // test case in nodeJs
	var t = nextInt();
	while(hasNext()){
		solve();
	}
}

function solve() {
	const n = nextInt();
	const arr = nextIntArray(n);

	const sum = arr.reduce((sum, ele) => sum + ele, 0);
	for (let i = 0; i < n; i++) {
		if (arr[i] === (sum - arr[i]) / (arr.length - 1)) {
			myout("YES");
			return;
		}
	}
	myout("NO");
}

'use strict';

function solve(n, a) {
  const sum = a.reduce((a, b) => a + b, 0);
  for (let i = 0; i < n; i++) {
    if (sum - a[i] === a[i] * (n - 1)) return 'YES';
  }
  return 'NO';
}

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

'use strict';
// HEADER:
const print = function(arg){
  let str = arg;
  if (arguments.length>1)
    str = Array.prototype.slice.call(arguments).join(' ');
  process.stdout.write(str+'\n');
};
let IS_MULTITEST, testN, tests;
const pcalc = (testN, toPrint)=>{
  let res = CALC(testN);
  if (Array.isArray(res)){
    toPrint.push(res.join(' '));
  } else if (Number.isFinite(res) || typeof res=='string'){
    toPrint.push(res+'');
  }
  if (process.env.DEBUG && toPrint.length){
    let ans = toPrint.pop();
    print(ans);
    let expected = tests[testN-1];
    if (expected){
      if (expected==ans)
        console.log('\x1b[32m%s\x1b[0m', 'correct');
      else {
        console.log('\x1b[31m%s\x1b[0m', 'wrong, expected:', expected);
      }
    }
  }
};

const main = ()=>{
  let toPrint = [];
  L('\nSolving:');
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(testN, toPrint);
  } else {
    pcalc(1, toPrint);
  }
  if (toPrint.length){
    print(toPrint.join('\n'));
  }
};

const lines = [];
const rl = require('readline').createInterface({
   input: process.stdin, output: process.stdout});
rl.on('line', line=>{
  lines.push(line);
});
rl.on('close', main);
let rli = 0;
const readline = ()=>lines[rli++];
const L = process.env.DEBUG ? console.log : ()=>{};
const LT = obj=>L(`\nTest #${testN}`, obj);

const ra = ()=>readline().split(' ').map(a=>+a)
const pa = arr=>print(arr.join(' '));

tests = [
``, // Test #1
``, // Test #2
``, // Test #3
``, // Test #4
``, // Test #5
];

// SOLUTION:
IS_MULTITEST = true;

const CALC = (testN)=>{
  // READING:
  let [n, m] = ra();
  let A = ra();
  LT({n, A});
  // PROCESSING:
  let ans = 0;
  for (let i=0; i<n; i++){
    let sum = 0;
    for (let j=0; j<n; j++){
      if (j==i)
        continue
      sum += A[j]
    }
    if (A[i]==sum/(n-1))
      return 'YES'
  }

  return 'NO';
};

"use strict";

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
    readline();
    var a = readline().split(" ").map(function (aa) {
        return parseInt(aa);
    });
    if (handle(a)) print("YES");else print("NO");
}

function handle(a) {
    var sum = 0;
    for (var j = 0; j < a.length; j++) {
        sum += a[j];
    }
    var avg = sum / a.length;

    for (var _i = 0; _i < a.length; _i++) {
        if (avg == a[_i]) return true;
    }
    return false;
}

var t = parseInt(readline());

for (var i=0; i<t; i++) {
    var n = parseInt(readline());
    var a = readline().split(" ").map( aa => parseInt(aa) );

    if (handle(a))
        print ("YES");
    else
        print ("NO");
}

function handle(a) {

    for (var i=0; i<a.length; i++) {
        var sum = 0;
        for (var j=0; j<a.length; j++) {
            sum += a[j];
        }
        sum = sum - a[i];
        var avg = sum / (a.length - 1);
        if (avg == a[i]) return true;
    }
    return false;
}

var num = readline();

for (var i = 0; i < num; i++) {
   var n = readline();
   var arr = readline().split(" ");

   var sum = 0;
   for(var k = 0; k < arr.length; k++){
      sum += parseInt(arr[k], 10);
   }
   var bool = false;
   sum = sum / n;
   for(var k = 0; k < arr.length; k++){
      if(arr[k] == sum) {
         bool = true;
      }
   }
   if(bool) {
      print("YES");
   } else {
      print("NO");
   }
}

T = readline()
while (T--) {
   n = +readline()
   a = readline().split(' ').map(a => +a)
   ans = 'NO'

   mesmo = 1

   for(i=0; i<n-1; i++){
      if(a[i] != a[i+1]){
         mesmo = 0
         break
      }
   }
   if(mesmo)
      ans = 'YES'

   if(!mesmo){
      for(i=0; i<n; i++){
         copy = a.slice()
         cur = copy.splice(i, 1)
         sum = 0
         for(j = 0; j< n-1; j++){
            sum += copy[j]

         }
         asum = sum / (n-1)
         if(asum == cur){
            ans = 'YES'
            break
         }
      }
   }
   print(ans)
}

var num = readline();

for (var i = 0; i < num; i++) {
   var n = readline();
   var arr = readline().split(" ");

   var sum = 0;
   for(var k = 0; k < arr.length; k++){
      sum += parseInt(arr[k], 10);
   }
   var bool = false;
   for(var k = 0; k < arr.length; k++){
      if(arr[k] == sum) {
         bool = true;
      }
   }
   if(bool) {
      print("YES");
   } else {
      print("NO");
   }
}

var num = readline();

for (var i = 0; i < num; i++) {
   var n = readline();
   var arr = readline().split(" ");

   var sum = 0;
   for(var k = 0; k < arr.length; k++){
      sum += arr[k];
   }
   var bool = false;
   for(var k = 0; k < arr.length; k++){
      if(arr[k] === sum) {
         bool = true;
      }
   }
   if(bool) {
      print("YES");
   } else {
      print("NO");
   }
}


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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    const n = parseInt(await getLine());
    const vertices = new Set();
    const stack = [];
    const addedge = function (a, b) {
        if (a > b) {
            addedge(b, a);
            return;
        }
        vertices.add(a + ' ' + b);
    }
    rl.output.write('? 1' + '\n');
    const d = (await getLine()).split(' ').map(num => parseInt(num));
    for (let i = 0; i < d.length; i++) {
        if (d[i] === 1) {
            addedge(1, i + 1);
        }
    }
    const maxPath = Math.max(...d);
    const cnt = new Array(n + 1);
    let sumOdd = 0;
    for (let i = 0; i < d.length; i++) {
        if (d[i] % 2 === 1)
            sumOdd++;
    }
    d.forEach((dist, index) => {
        if (sumOdd < n - sumOdd && dist % 2 === 1)
            stack.push(index + 1);
        else if (sumOdd >= n - sumOdd && dist % 2 === 0 && dist !== 0)
            stack.push(index + 1);
    })

    for (let j = 0; j < stack.length; j++) {
        const v = stack[j];
        rl.output.write('? ' + v + '\n');
        const d = (await getLine()).split(' ').map(num => parseInt(num));
        for (let i = 0; i < d.length; i++) {
            if (d[i] === 1) {
                addedge(v, i + 1);
            }
        }
    }

    rl.output.write('!\n');
    vertices.forEach(v => {
        rl.output.write(v + '\n');
    });
}

solve();

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    const n = parseInt(await getLine());
    const vertices = new Set();
    const stack = [];
    const addedge = function (a, b) {
        if (a > b) {
            addedge(b, a);
            return;
        }
        vertices.add(a + ' ' + b);
    }
    rl.output.write('? 1' + '\n');
    const d = (await getLine()).split(' ').map(num => parseInt(num));
    for (let i = 0; i < d.length; i++) {
        if (d[i] === 1) {
            addedge(1, i + 1);
        }
    }
    let sumOdd = d.reduce((prev, cur) => { return prev + cur % 2; }, 0);

    d.forEach((dist, index) => {
        if (sumOdd < n - sumOdd && dist % 2 === 1)
            stack.push(index + 1);
        else if (sumOdd >= n - sumOdd && dist % 2 === 0 && dist !== 0)
            stack.push(index + 1);
    })

    for (let j = 0; j < stack.length; j++) {
        const v = stack[j];
        rl.output.write('? ' + v + '\n');
        const d = (await getLine()).split(' ').map(num => parseInt(num));
        for (let i = 0; i < d.length; i++) {
            if (d[i] === 1) {
                addedge(v, i + 1);
            }
        }
    }

    rl.output.write('!\n');
    vertices.forEach(v => {
        rl.output.write(v + '\n');
    });
}

solve();

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    const n = parseInt(await getLine());
    const vertices = new Set();
    const stack = [];
    const addedge = function (a, b) {
        if (a > b) {
            addedge(b, a);
            return;
        }
        vertices.add(a + ' ' + b);
    }
    rl.output.cork();
    rl.output.write('? 1' + '\n');
    rl.output.uncork();
    const d = (await getLine()).split(' ').map(num => parseInt(num));
    for (let i = 0; i < d.length; i++) {
        if (d[i] === 1) {
            addedge(1, i + 1);
        }
    }
    const maxPath = Math.max(...d);
    const cnt = new Array(n + 1);
    let sumOdd = 0;
    for (let i = 0; i < d.length; i++) {
        if (d[i] % 2 === 1)
            sumOdd++;
    }
    d.forEach((dist, index) => {
        if (sumOdd < n - sumOdd && dist % 2 === 1)
            stack.push(index + 1);
        else if (sumOdd >= n - sumOdd && dist % 2 === 0 && dist !== 0)
            stack.push(index + 1);
    })

    for (let j = 0; j < stack.length; j++) {
        const v = stack[j];
        rl.output.cork();
        rl.output.write('? ' + v + '\n');
        rl.output.uncork();
        const d = (await getLine()).split(' ').map(num => parseInt(num));
        for (let i = 0; i < d.length; i++) {
            if (d[i] === 1) {
                addedge(v, i + 1);
            }
        }
    }

    rl.output.write('!\n');
    vertices.forEach(v => {
        rl.output.write(v + '\n');
    });
}

solve();

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    const n = parseInt(await getLine());
    const vertices = new Set();
    const stack = [1];
    const addedge = function (a, b) {
        if (a > b) {
            addedge(b, a);
            return;
        }
        vertices.add(a + ' ' + b);
    }
    const was = new Array(n + 1);
    was[1] = true;
    while (vertices.size < n - 1) {
        const v = stack.shift();
        rl.output.write('? ' + v + '\n');
        const d = (await getLine()).split(' ').map(num => parseInt(num));
        let ones = 0;
        let onev;
        for (let i = 0; i < d.length; i++) {
            if (d[i] === 1) {
                ones++;
                onev = i + 1;
                addedge(v, i + 1);
            } /* else if (d[i] === 2 && !was[i + 1]) {
                stack.push(i + 1);
            } */
        }
        if (ones == 1) {
            for (let i = 0; i < d.length; i++) {
                if (d[i] === 2) {
                    addedge(onev, i + 1);
                }
            }
        }

        for (let i = 0; i < d.length; i++) {
            if (d[i] === 2 && !was[i+1]) {
                was[i + 1] = true;
                stack.push(i + 1);
            }
        }

    }

    console.log('!');
    vertices.forEach(v => {
        console.log(v);
    });
}

solve();

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    const n = parseInt(await getLine());
    const vertices = new Set();
    const stack = [1];
    const addedge = function(a, b) {
       if (a > b) {
           addedge(b, a);
           return;
       }
       vertices.add(a + ' ' + b);
    }
    const was = new Array(n + 1);

    while (vertices.size < n - 1) {
        const v = stack.shift();
        rl.output.write('? ' + v + '\n');
        const d = (await getLine()).split(' ').map(num => parseInt(num));
        for(let i = 0; i < d.length; i++) {
            if (d[i] === 1) {
                addedge(v, i + 1);
            } else if (d[i] === 2 && !was[i + 1]) {
                stack.push(i + 1);
            }
        }
    }

    console.log('!');
    vertices.forEach(v => {
        console.log(v);
    });
}

solve();


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

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

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

const mxN = 40001;
const MOD = 1e9+7;

const f = Array(mxN).fill(0); f[0] = 1;

function reverse (n) {
	n = String(n);
	n = n.split('');
	n = n.reverse();
	n = n.join('');
	n = Number(n);
	return n;
}

function compute () {
	for (let p = 1; p < mxN; p++) {
		if (p != reverse(p)) continue;
		for (let i = p; i < mxN; i++) {
			f[i] += f[i-p];
			f[i] %= MOD;
		}
	}
}

function main () {
	compute();
	let T = rn();
	while (T--) {
		const n = rn();
		console.log(f[n]);
	}
}

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)
    }
    console.log(output.join('\n'))
// })()
})

const CACHE = pre(4e4)
function pre(n) {
    const ps = []
    for (let i = 1; i <= n; i++) {
        const a = String(i)
        let ok = true
        for (let j = 0; j < a.length; j++) {
            if (a[j] !== a[a.length - 1 - j]) {
                ok = false
                break
            }
        }
        if (ok) ps.push(i)
    }
    //
    const dp = []
    for (let j = 0; j < ps.length; j++) {
        if (!j) {
            dp[j] = Array(n + 1).fill(1)
            continue
        }
        dp[j] = dp[j - 1].slice()
        for (let i = ps[j]; i <= n; i++) {
            const k = Math.floor(i / ps[j])
            dp[j][i] = dp[j][i - ps[j]]
            dp[j][i] = add(dp[j][i], dp[j - 1][i] || 1)
            // for (let k = 0; k * ps[j] <= i; k++) {
            //     // dp[j][i] = dp[j - 1][i] + dp[j - 1][i - ps[j] * k]
            //     dp[j][i] = add(dp[j][i], dp[j - 1][i - ps[j] * k] || 1)
            // }
        }
    }
// console.log(dp)
    // for (let i = 1; i <= n; i++) {
    //     dp[i] = []
    //     let prev
    //     for (let j = 0; j < ps.length; j++) {
    //         if (ps[j] > i) {
    //             dp[i][j] = prev
    //             continue
    //         }

    //         let now = 0
    //         for (let k = 0; k <= j; k++) {
    //             const max = ps[k]
    //             now = add(now, i === max ? 1 : dp[i - max][k])
    //         }
    //         dp[i][j] = now
    //         prev = now
    //     }
    // }
    return dp[ps.length - 1]
}
function solve(n) {
    return CACHE[n]
}
function add(a, b) {
    return (a + b) % (1e9 + 7)
}

'use strict';

const f = [];
const N = 4 * 10 ** 4 + 10;
for (let i = 1; i < N; i++) {
  if (i.toString() === i.toString().split('').reverse().join('')) f.push(i);
}
const m = f.length;
const dp = new Array(N).fill(0);
const MOD = 10 ** 9 + 7;
const mod = num => num >= MOD ? (num % MOD + MOD) % MOD : num;
dp[0] = 1;
for (let i = 0; i < m; i++) {
  for (let j = 0; j < N; j++) {
    const k = f[i] + j;
    dp[k] = mod(dp[k] + dp[j]);
  }
}
function solve(n) {
  return dp[n];
}

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

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

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

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

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

const mxN = 40001;
const mxM = 500;

const pal = [];
const f = Array.from(Array(mxN), _ => Array(mxM).fill(0));

function reverse (n) {
	n = String(n);
	n = n.split('');
	n = n.reverse();
	n = n.join('');
	n = Number(n);
	return n;
}

function compute () {
	for (let i = 1; i < mxN; i++) {
		if (i == reverse(i)) {
			pal.push(i);
		}
	}

	for (let i = 0; i < pal.length; i++) {
		f[1][i] = 1, f[0][i] = 1;
	}

	for (let i = 2; i < mxN; i++) {
		for (j = 0; j < pal.length; j++) {
			f[i][j] = j-1 >= 0 ? f[i][j-1] : 0;
			f[i][j] += i-pal[j] >= 0 ? f[i-pal[j]][j] : 0;
		}
	}
}

function main () {
	compute();
	let T = rn();
	while (T--) {
		const n = rn();
		console.log(f[n][pal.length-1]);
	}
}


'use strict'
Object.defineProperty(exports, '__esModule', { value: !0 })
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  lineIndex = 0
  lines = []
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const e = this.lines[this.lineIndex]
    return (this.lineIndex += 1), e
  }
  readLineAsNumber() {
    return Number(this.readLine())
  }
  readIntegersOfLine() {
    const e = this.readLine().match(integerRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  readNumsOfLine() {
    const e = this.readLine().match(decimalRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  print(e) {
    stdout.write(e)
  }
  async init() {
    const e = await this.readLines()
    this.lines = e
  }
  readLines() {
    const e = []
    return new Promise(n => {
      stdin.on('data', n => e.push(n)),
        stdin.on('end', function () {
          const t = e.join('').split(os.EOL)
          n(t)
        })
    })
  }
}
async function __main__(e) {
  const n = new InputAndOutput()
  await n.init(), e(n)
}
const nums = new Array(10010).fill(0).map((e, n) => n)
function solve(e, n) {
  if (0 === n[e - 1]) return nums.slice(1, e + 2)
  if (1 === n[0]) return [e + 1].concat(nums.slice(1, e + 1))
  let t = 0
  for (let s = e - 1; t < s && (0 !== n[t] || 1 !== n[t + 1]); ++t);
  if (t === e - 1) return -1
  const s = nums.slice(1, t + 2)
  s.push(e + 1)
  for (let n = t + 1; n < e; ++n) s.push(n + 1)
  return s
}
__main__(function (e) {
  const n = e.readLineAsNumber()
  for (let t = 1; t <= n; ++t) {
    const n = solve(e.readLineAsNumber(), e.readIntegersOfLine())
    ;-1 === n ? e.print(n + '\n') : e.print(n.join(' ') + '\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++];
}
let arr = [];
const precompute = () => {
  arr.push(1n);
  let k = 2n;
  for (let i = 1; i < 51; i++, k = k * 2n) arr[i] = k;
};
const solve = () => {
  precompute();
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let dir = new Array(n).fill(0).map((cur, ind) => ind + 1);
    for (let i = n - 1; i >= 0; i--) {
      if (arr[i] === 0) break;
      else dir.pop();
    }
    if (dir.length) {
      let s = dir[dir.length - 1];
      s++;
      dir.push(n + 1);
      while (s <= n) dir.push(s++);
      console.log(dir.join(" "));
    } else {
      let res = `${n + 1} `,
        i = 1;
      while (i <= n) res += `${i++} `;
      console.log(res);
    }
  }
};
solve();

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 ans = Array.from(Array(n), (_, i) => i + 1);
		if (a[0]) {
			ans.unshift(n + 1);
		} else if (!a[n - 1]) {
			ans.push(n + 1);
		} else if (a.join('').includes('01')) {
			for (let i = 0; i < n - 1; ++i) {
				if (!a[i] && a[i + 1]) {
					ans.splice(i + 1, 0, n + 1);
					break;
				}
			}
		} else {
			ans = false;
		}

		console.log(ans ? ans.join(' ') : -1);
	}
}

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 = rn();
		let a = rna();

		let ans = Array.from(Array(n), (_, i) => i+1);
		if (a[n-1] == 0) {
			ans.push(n+1);
		} else if (a[0] == 1) {
			ans.unshift(n+1);
		} else if (a.join('').includes('01')) {
			for (let i = 0; i < n-1; i++) {
				if (a[i] == 0 && a[i+1] == 1) {
					ans.splice(i+1, 0, n+1);
					break;
				}
			}
		} else {
			ans = false;
		}

		console.log(ans ? ans.join(' ') : -1);
	}
}

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 = rn();
		let a = rna();

		let ans = Array.from(Array(n), (_, i) => i+1);
		if (a[n-1] == 0) {
			ans.push(n+1);
		} else if (a[0] == 1) {
			ans.unshift(n+1);
		} else if (a.join('').includes('01')) {
			for (let i = 0; i < n-1; i++) {
				if (a[i] == 0 && a[i+1] == 1) {
					a.splice(i+1, 0, n+1);
					break;
				}
			}
		} else {
			ans = false;
		}

		console.log(ans ? ans.join(' ') : -1);
	}
}

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 = rn();
		let a = rna();

		let ans = Array.from(Array(n), (_, i) => i+1);
		if (a[n-1] == 0) {
			ans.push(n+1);
		} else if (a[0] == 1) {
			ans.unshift(n+1);
		} else if (a.join('').includes('01')) {
			for (let i = 1; i < n-1; i++) {
				if (a[i] == 0 && a[i+1] == 1) {
					a.splice(i+1, 0, n+1);
					break;
				}
			}
		} else {
			ans = false;
		}

		console.log(ans ? ans.join(' ') : -1);
	}
}

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

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

const RANGE = (s, e) => Array.from(Array(e - s + 1), (_, index) => index + s);

function main ()     {
	let t = rl();
	while (t--) {
		let n = rl();
		let a = rl();

		let ans = [], i = 0;
		while (i < n && a[i] == 0) i++;
		if (i != n ) {
			ans = [...RANGE(1, i), n + 1, ...RANGE(i + 1, n)];
		}

		console.log(ans.length == 0 ? -1 : ans.join(' '))
	}
}


const { createInterface } = require('readline');
const lines = []

const numbers = [4, 8, 15, 16, 23, 42];

const map = {};
for (let i = 0; i < 6; i ++) {
    for (let j = i +1; j < 6; j++) {
        map[numbers[i] * numbers[j]] = [numbers[i], numbers[j]];
    }
}

const found = [];

const nums = [];

function solve() {
    if (nums[0][0] === nums[1][0]) {
        found.push(nums[0][1], nums[0][0], nums[1][1])
    } else if (nums[0][0] === nums[1][1]) {
        found.push(nums[0][1], nums[0][0], nums[1][0])
    } else if (nums[0][1] === nums[1][0]) {
        found.push(nums[0][0], nums[0][1], nums[1][1])
    } else if (nums[0][1] === nums[1][1]) {
        found.push(nums[0][0], nums[0][1], nums[1][0])
    }
    numbers.forEach((num) => {
        if (!found.includes(num)) {
            found.push(num);
        }
    })

    console.log(`! ${found.join(' ')}`)
}

console.log('? 1 1');
let iter = 1;

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

    rl.on('line', (line) => {
       switch (iter) {
        case 1:
            found.push(parseInt(Math.sqrt(+line)));
            console.log('? 2 2');
            iter++;
            break;
        case 2:
            found.push(parseInt(Math.sqrt(+line)));
            console.log('? 3 4');
            iter++;
            break;
        case 3:
            nums.push(map[line])
            console.log('? 4 5');
            iter++;
            break;
       case 4:
            nums.push(map[line])
            iter++;
            solve();
            break;
        case 5:
            process.exit(0);
       }
    });

})();

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var arr = [4 , 8, 15, 16, 23, 42];
    var muls = [];

    for(var i = 2; i < 6; i++) {
        print('? 1 ' + i );
        muls.push(read.number());
    }

    var first;
    for(var i = 0; i < 6; i++) {
        var ch = true;
        for(var j = 0; j < 4; j++) {
            if(arr.indexOf(muls[j] / arr[i]) === -1) {
                ch = false;
                break;
            }
        }
        if(ch) {
            first = arr[i];
            break;
        }
    }

    var res = [first];
    muls.forEach(v => res.push(v/first));
    arr.forEach(v => {
        if(res.indexOf(v) === -1) {
            res.push(v);
        }
    });

    print('! ' + res.join(' '));

}());

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var arr = [4 , 8, 15, 16, 23, 42];
    var muls = [];

    for(var i = 2; i < 6; i++) {
        print('? 1 ' + i );
        muls.push(read.number());
    }

    var first;
    for(var i = 0; i < 6; i++) {
        var ch = true;
        for(var j = 0; j < 4; j++) {
            if(arr.indexOf(muls[j] / arr[i]) === -1) {
                ch = false;
                break;
            }
        }
        if(ch) {
            first = arr[i];
            break;
        }
    }

    var res = [first];
    muls.forEach(v => res.push(v/first))

    arr.forEach(v => {
        if(res.indexof(v) === -1) {
            res.push(v);
        }
    });

    print(res.join(' '));

}());


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

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

void (function main() {
  const t = Number(inputs[0])
  for (let _ = 0; _ < t; _++) {
    const n = inputs[_ + 1]
    console.log([1, n - 3, 1, 1].join(' '))
  }
})()

let buf='';

process.stdin.on('readable', function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end', function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let _=1;_<=t;_++)
    {
        let n=parseInt(line[_]);
        let ans='';
        ans+=n-3+' ';
        ans+=1+' ';
        ans+=1+' ';
        ans+=1+' ';
        console.log(ans);
    }
})

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

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

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

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);
        output(`${n - 3} 1 1 1`);
    }
}

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

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

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    let n = parseInt(readLine());
    return `${n - 3} 1 1 1`;
}

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

module.exports = E;

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

const MOD = 1e9+7;

class SegmTree {

}

const calc = (n)=>{
  let ans = [1, n-3, 1, 1];
  return ans.join(' ');
};

function main() {
    let T = +readline()
    while (T--){
      let [n] = ra();
      l('ans')
      print(calc(n));
    }
}

E.calc = calc;

var tests = readline();

while(tests--) {
    var x = readline();

    print(x-3 + ' 1 1 1');
}

var total = +readline();
while (total--) {
    var i = +readline();
    print(i - 3 + " 1 1 1");
}

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

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

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

void (function main() {
  const t = Number(inputs[0])
  for (let _ = 0; _ < t; _++) {
    const n = inputs[_ + 1]
    console.log([1, 1, 1, n - 3].join(' '))
  }
})()