Consider a conveyor belt represented using a grid consisting of $$$n$$$ rows and $$$m$$$ columns. The cell in the $$$i$$$-th row from the top and the $$$j$$$-th column from the left is labelled $$$(i,j)$$$. Every cell, except $$$(n,m)$$$, has a direction R (Right) or D (Down) assigned to it. If the cell $$$(i,j)$$$ is assigned direction R, any luggage kept on that will move to the cell $$$(i,j+1)$$$. Similarly, if the cell $$$(i,j)$$$ is assigned direction D, any luggage kept on that will move to the cell $$$(i+1,j)$$$. If at any moment, the luggage moves out of the grid, it is considered to be lost. There is a counter at the cell $$$(n,m)$$$ from where all luggage is picked. A conveyor belt is called functional if and only if any luggage reaches the counter regardless of which cell it is placed in initially. More formally, for every cell $$$(i,j)$$$, any luggage placed in this cell should eventually end up in the cell $$$(n,m)$$$. This may not hold initially; you are, however, allowed to change the directions of some cells to make the conveyor belt functional. Please determine the minimum amount of cells you have to change.Please note that it is always possible to make any conveyor belt functional by changing the directions of some set of cells.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n, m$$$ ($$$1 \le n \le 100$$$, $$$1 \le m \le 100$$$)  — the number of rows and columns, respectively. The following $$$n$$$ lines each contain $$$m$$$ characters. The $$$j$$$-th character in the $$$i$$$-th line, $$$a_{i,j}$$$ is the initial direction of the cell $$$(i, j)$$$. Please note that $$$a_{n,m}=$$$ C.

For each case, output in a new line the minimum number of cells that you have to change to make the conveyor belt functional.

4
3 3
RRD
DDR
RRC
1 4
DDDC
6 9
RDDDDDRRR
RRDDRRDDD
RRDRDRRDR
DDDDRDDRR
DRRDRDDDR
DDRDRRDDC
1 1
C

NoteIn the first case, just changing the direction of $$$(2,3)$$$ to D is enough.You can verify that the resulting belt is functional. For example, if we place any luggage at $$$(2,2)$$$, it first moves to $$$(3,2)$$$ and then to $$$(3,3)$$$. In the second case, we have no option but to change the first $$$3$$$ cells from D to R making the grid equal to RRRC.

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var changes = 0;
    var nm = readNumArray();
    var n = nm[0];
    var m = nm[1];
    for (var j = 0; j < n; j++) {
      var next = readline();
      if (j < n - 1 && next[m - 1] === 'R') {
        changes ++;
      }
      if (j === n - 1) {
        for (var k = 0; k < m - 1; k++) {
          if (next[k] === 'D') {
            changes++;
          }
        }
      }
    }
    print(changes);
  }
}

main();

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const x = readline();
    var cases = parseInt(x);
    //console.log("Cases",cases);
    for(var i=1;i<=cases;i++){
         //console.log("case ",i);
         var line2 = readline();
         var dims = line2.split(" ");
         var row = parseInt(dims[0]);
         var col = parseInt(dims[1]);

         var arr = [];
         for(var p=0;p<row;p++){
             var rowStr = readline();
             // console.log("current ",rowStr);
             var rows = rowStr.split("");
             arr.push(rows);
         }
         console.log(minChangesRequired(arr));
    }

}
function getGoodPermutation(x) {
    var strs = [];
    for(var i=1;i<=x;i++){
        strs.push(i);
    }
    return strs.join(" ");
}

function minChangesRequired(arr){
    var minChanges = 0;

    var lastRow = arr.length-1;

    var lastColumn = arr[0].length-1;

    for(var j = 0;j<lastColumn;j++){
        if(arr[lastRow][j] == 'D'){
            minChanges++;
        }
    }
    for(var k =0;k<lastRow;k++){
        if(arr[k][lastColumn] == 'R'){
            minChanges++;
        }
    }
    return minChanges;
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const [row, col] = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    let i = 0;
    let count = 0;
    const store = [];
    while (i < row) {
      const r = readLine().split("");
      store.push(r);
      if (r[col - 1] === "R") count++;
      i++;
    }
    for (let i = 0; i < col; i++) {
      if (store[row - 1][i] === "D") count++;
    }

    console.log(count);
  }
}

//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 t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
  	var one = nextIntArray();
  	var N = one[0];
  	var M = one[1];
  	var list = new Array(N);
  	for(var j = 0; j < N; j++){
  		list[j] = nextCharArray();
  	}
  	var count = 0;
  	for(var j = 0; j < N - 1; j++){
  		if(list[j][M - 1] == "R"){
  			count++;
  		}
  	}
  	for(var j = 0; j < M; j++){
  		if(list[N - 1][j] == "D"){
  			count++;
  		}
  	}
  	output[i] = count;
  }
  myout(myconv(output, 9));
}

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

let stdinInput = '';

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

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

function main(data) {
	data = data.split('\n');
	const testCases = data[0] * 1;
	let i = 1;
	let r = 1;
	while (i <= testCases) {
    let num = data[r].trim().split(' ').map(Number);
    let n = num[0] * 1;
    let m = r + 1;
    r += n + 1;
    let count = 0;
    let arr = [];
    for (let j = m; j < r; j += 1) arr.push(data[j].trim());
    if (n === 1) {
      for (let j = 0; j < arr[0].length; j += 1) {
        if (arr[0][j] === 'D') count += 1;
      }
    } else {
      for (let j = 0; j < arr.length; j += 1) {
        if (arr[j][arr[j].length - 1] === 'R') count += 1;
      }
      for (let j = 0; j < arr[arr.length - 1].length - 1; j += 1) {
        if (arr[arr.length - 1][j] === 'D') count += 1;
      }
    }
    console.log(count);
    i += 1;
	}
}

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

let inputString = '';
let currentLine = 0;

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

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

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

function main() {
  const t = Number(readLine())
  for (let i = 0; i < t; i++) {
    const [n, m] = readLine().split(/\s/).map(Number)
    let result = 0;
    for (let r = 0; r < n; r++) {
      const row = readLine()
      if (r === n - 1) {
        for (let c = 0; c < m - 1; c++) {
          if (row[c] === 'D') {
            result += 1
          }
        }
      } else if (row[m - 1] === 'R') {
        result += 1
      }
    }
    console.log(result)
  }
}

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

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

function main() {
	let t = readLine() >> 0;
	while (t--) {
		let [n, m] = readLine()
			.split(' ')
			.map(x => x >> 0);
		let arr = [],
			c = 0;

		for (let i = 0; i < n; ++i) {
			let l = readLine().split('');
			arr.push(l);
			if (arr[i][m - 1] === 'R') c++;
			if (i === n - 1) {
				for (let j = 0; j < m - 1; j++) if (arr[n - 1][j] === 'D') c++;
			}
		}

		console.log(c);
	}
}

'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++];
}
/**
6
1 1 1 2 1 1
6
+ 2
+ 1
- 1
+ 2
- 1
+ 2

**/

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

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve(index) {
    let [n, m] = readline().split(" ").map(Number);

    let a = [];

    for(let i=0;i<n;i++) {
        a[i] = [...readline().split("")];
    }

    let count = 0;

    for(let i=0;i<m-1;i++) {
        if(a[n-1][i] === 'D') {
            count++;
        }
    }

    for(let i=0;i<n;i++) {
        if(a[i][m-1] === 'R') {
            count++;
        }
    }

    console.log(count);

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const x = readline();
    var cases = parseInt(x);
    //console.log("Cases",cases);
    for(var i=1;i<=cases;i++){
         //console.log("case ",i);
         var line2 = readline();
         var dims = line2.split(" ");
         var row = parseInt(dims[0]);
         var col = parseInt(dims[1]);

         var arr = [];
         for(var p=0;p<row;p++){
             var rowStr = readline();
             // console.log("current ",rowStr);
             var rows = rowStr.split("");
             arr.push(rows);
         }
         console.log(minChanges(arr));
    }

}
function getGoodPermutation(x) {
    var strs = [];
    for(var i=1;i<=x;i++){
        strs.push(i);
    }
    return strs.join(" ");
}

function minChanges(arr){
   var pathCovered = [];

   var dp = [];

   for(var i =0; i<arr.length;i++){
       var rw = [];
       var cl = arr[0].length;
       for(var j=0;j<cl;j++){
           rw.push(0);
       }
       dp.push(rw);
   }

   dp[0][0] = 0;

   var cleng = arr[0].length;

   var rowLast = arr[arr.length-1][cleng-1];

   for(var row = 0;row<arr.length;row++){
       var colLength = arr[0].length;
       for(var col = 0; col < colLength ; col++){
           var minValFromLeft = 10000;
           var minValFromTop = 10000;
           if(row === 0 && col === 0){
              minValFromLeft = 0;
              minValFromTop = 0;
           }
           if(col>0){
               var leftElem = arr[row][col-1];
               if(leftElem == "R"){
                  minValFromLeft = dp[row][col-1];
               }
               else{
                minValFromLeft = 1+dp[row][col-1];
               }
           }
           if(row>0){
                var topElem = arr[row-1][col];
                if(topElem == "D"){
                    minValFromTop = dp[row-1][col];
                }
                else{
                    minValFromTop = 1+dp[row-1][col];
                }
           }
          dp[row][col] = Math.min(minValFromLeft,minValFromTop);
       }
   }

   return dp[arr.length-1][cleng-1];
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const x = readline();
    var cases = parseInt(x);
    console.log("Cases",cases);
    for(var i=1;i<=cases;i++){
         //console.log("case ",i);
         var line2 = readline();
         var dims = line2.split(" ");
         var row = parseInt(dims[0]);
         var col = parseInt(dims[1]);

         var arr = [];
         for(var p=0;p<row;p++){
             var rowStr = readline();
             // console.log("current ",rowStr);
             var rows = rowStr.split("");
             arr.push(rows);
         }
         console.log(minChanges(arr));
    }

}
function getGoodPermutation(x) {
    var strs = [];
    for(var i=1;i<=x;i++){
        strs.push(i);
    }
    return strs.join(" ");
}

function minChanges(arr){
   var pathCovered = [];

   var dp = [];

   for(var i =0; i<arr.length;i++){
       var rw = [];
       var cl = arr[0].length;
       for(var j=0;j<cl;j++){
           rw.push(0);
       }
       dp.push(rw);
   }

   dp[0][0] = 0;

   var cleng = arr[0].length;

   var rowLast = arr[arr.length-1][cleng-1];

   for(var row = 0;row<arr.length;row++){
       var colLength = arr[0].length;
       for(var col = 0; col < colLength ; col++){
           var minValFromLeft = 10000;
           var minValFromTop = 10000;
           if(row === 0 && col === 0){
              minValFromLeft = 0;
              minValFromTop = 0;
           }
           if(col>0){
               var leftElem = arr[row][col-1];
               if(leftElem == "R"){
                  minValFromLeft = dp[row][col-1];
               }
               else{
                minValFromLeft = 1+dp[row][col-1];
               }
           }
           if(row>0){
                var topElem = arr[row-1][col];
                if(topElem == "D"){
                    minValFromTop = dp[row-1][col];
                }
                else{
                    minValFromTop = 1+dp[row-1][col];
                }
           }
          dp[row][col] = Math.min(minValFromLeft,minValFromTop);
       }
   }

   return dp[arr.length-1][cleng-1];
}

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

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

function main() {
	let t = readLine() >> 0;
	while (t--) {
		let [n, m] = readLine()
			.split(' ')
			.map(x => x >> 0);
		let arr = [];
		for (let i = 0; i < n; i++) arr[i] = readLine().split('');
		let c = 0;
		for (let i = 0; i < m - 1; ++i) if (arr[0][i] !== 'R') c++;
		if (arr[0][m - 1] === 'R') c++;
		for (let i = 1; i < n - 1; ++i) if (arr[i][m - 1] !== 'D') c++;

		console.log(c);
	}
}

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

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

function main() {
	let t = readLine() >> 0;
	while (t--) {
		let [n, m] = readLine()
			.split(' ')
			.map(x => x >> 0);
		let arr = [];
		for (let i = 0; i < n; i++) arr[i] = readLine().split('');

		let c = 0;
		for (let i = 0; i < n - 1; ++i)
			if (arr[i][m - 1] !== 'D') {
				c++;
				arr[i][m - 1] = 'D';
			}

		for (let x = 0; x < m - 1; x++) {
			if (arr[0][x] === 'R') continue;
			let i = 0,
				j = x;
			while (i < n && j < m) {
				if (arr[i][j] === 'R') j++;
				else i++;
			}
			if (i !== n || j !== m) {
				c++;
			}
		}

		console.log(c);
	}
}

'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++];
}
/**
6
1 1 1 2 1 1
6
+ 2
+ 1
- 1
+ 2
- 1
+ 2

**/

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

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve(index) {
    let [n, m] = readline().split(" ").map(Number);

    let a = [];

    for(let i=0;i<n;i++) {
        a[i] = [...readline().split("")];
    }

    let count = 0;

    for(let i=0;i<m-1;i++) {
        if(a[0][i] === 'D') {
            count++;
        }
    }

    for(let i=0;i<n;i++) {
        if(a[i][m-1] === 'R') {
            count++;
        }
    }

    console.log(count);

}


You are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element of this subarray strictly greater than previous.

The first line contains single positive integer n (1 ≤ n ≤ 105) — the number of integers. The second line contains n positive integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Print the maximum length of an increasing subarray of the given array.

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

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

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

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

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

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)

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


You are given an array of $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$. After you watched the amazing film "Everything Everywhere All At Once", you came up with the following operation.In one operation, you choose $$$n-1$$$ elements of the array and replace each of them with their arithmetic mean (which doesn't have to be an integer). For example, from the array $$$[1, 2, 3, 1]$$$ we can get the array $$$[2, 2, 2, 1]$$$, if we choose the first three elements, or we can get the array $$$[\frac{4}{3}, \frac{4}{3}, 3, \frac{4}{3}]$$$, if we choose all elements except the third.Is it possible to make all elements of the array equal by performing a finite number of such operations?

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$3 \le n \le 50$$$)  — the number of integers. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 100$$$).

For each test case, if it is possible to make all elements equal after some number of operations, output $$$\texttt{YES}$$$. Otherwise, output $$$\texttt{NO}$$$. You can output $$$\texttt{YES}$$$ and $$$\texttt{NO}$$$ in any case (for example, strings $$$\texttt{yEs}$$$, $$$\texttt{yes}$$$, $$$\texttt{Yes}$$$ will be recognized as a positive response).

NoteIn the first test case, all elements are already equal.In the second test case, you can choose all elements except the third, their average is $$$\frac{1 + 2 + 4 + 5}{4} = 3$$$, so the array will become $$$[3, 3, 3, 3, 3]$$$.It's possible to show that it's impossible to make all elements equal in the third and fourth test cases.

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

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

//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");
   }
}


This is an interactive problem.Little Dormi was faced with an awkward problem at the carnival: he has to guess the edges of an unweighted tree of $$$n$$$ nodes! The nodes of the tree are numbered from $$$1$$$ to $$$n$$$.The game master only allows him to ask one type of question: Little Dormi picks a node $$$r$$$ ($$$1 \le r \le n$$$), and the game master will reply with an array $$$d_1, d_2, \ldots, d_n$$$, where $$$d_i$$$ is the length of the shortest path from node $$$r$$$ to $$$i$$$, for all $$$1 \le i \le n$$$.Additionally, to make the game unfair challenge Little Dormi the game master will allow at most $$$\lceil\frac{n}{2}\rceil$$$ questions, where $$$\lceil x \rceil$$$ denotes the smallest integer greater than or equal to $$$x$$$.Faced with the stomach-churning possibility of not being able to guess the tree, Little Dormi needs your help to devise a winning strategy!Note that the game master creates the tree before the game starts, and does not change it during the game.

The first line of input contains the integer $$$n$$$ ($$$2 \le n \le 2\,000$$$), the number of nodes in the tree. You will then begin interaction.

When your program has found the tree, first output a line consisting of a single "!" followed by $$$n-1$$$ lines each with two space separated integers $$$a$$$ and $$$b$$$, denoting an edge connecting nodes $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le n$$$). Once you are done, terminate your program normally immediately after flushing the output stream. You may output the edges in any order and an edge $$$(a,b)$$$ is considered the same as an edge $$$(b,a)$$$. Answering is not considered as a query.

NoteHere is the tree from the first example.  Notice that the edges can be output in any order.Additionally, here are the answers for querying every single node in example $$$1$$$: $$$1$$$: $$$[0,1,2,2]$$$  $$$2$$$: $$$[1,0,1,1]$$$  $$$3$$$: $$$[2,1,0,2]$$$  $$$4$$$: $$$[2,1,2,0]$$$Below is the tree from the second example interaction.  Lastly, here are the answers for querying every single node in example $$$2$$$: $$$1$$$: $$$[0,4,1,3,2]$$$  $$$2$$$: $$$[4,0,3,1,2]$$$  $$$3$$$: $$$[1,3,0,2,1]$$$  $$$4$$$: $$$[3,1,2,0,1]$$$  $$$5$$$: $$$[2,2,1,1,0]$$$

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


You are given a positive integer $$$n$$$. Let's call some positive integer $$$a$$$ without leading zeroes palindromic if it remains the same after reversing the order of its digits. Find the number of distinct ways to express $$$n$$$ as a sum of positive palindromic integers. Two ways are considered different if the frequency of at least one palindromic integer is different in them. For example, $$$5=4+1$$$ and $$$5=3+1+1$$$ are considered different but $$$5=3+1+1$$$ and $$$5=1+3+1$$$ are considered the same. Formally, you need to find the number of distinct multisets of positive palindromic integers the sum of which is equal to $$$n$$$.Since the answer can be quite large, print it modulo $$$10^9+7$$$.

The first line of input contains a single integer $$$t$$$ ($$$1\leq t\leq 10^4$$$) denoting the number of testcases. Each testcase contains a single line of input containing a single integer $$$n$$$ ($$$1\leq n\leq 4\cdot 10^4$$$) — the required sum of palindromic integers.

For each testcase, print a single integer denoting the required answer modulo $$$10^9+7$$$.

NoteFor the first testcase, there are $$$7$$$ ways to partition $$$5$$$ as a sum of positive palindromic integers:   $$$5=1+1+1+1+1$$$  $$$5=1+1+1+2$$$  $$$5=1+2+2$$$  $$$5=1+1+3$$$  $$$5=2+3$$$  $$$5=1+4$$$  $$$5=5$$$ For the second testcase, there are total $$$77$$$ ways to partition $$$12$$$ as a sum of positive integers but among them, the partitions $$$12=2+10$$$, $$$12=1+1+10$$$ and $$$12=12$$$ are not valid partitions of $$$12$$$ as a sum of positive palindromic integers because $$$10$$$ and $$$12$$$ are not palindromic. So, there are $$$74$$$ ways to partition $$$12$$$ as a sum of positive palindromic integers.

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

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


Dreamoon likes to play with sets, integers and .  is defined as the largest positive integer that divides both a and b.Let S be a set of exactly four distinct integers greater than 0. Define S to be of rank k if and only if for all pairs of distinct elements si, sj from S, .Given k and n, Dreamoon wants to make up n sets of rank k using integers from 1 to m such that no integer is used in two different sets (of course you can leave some integers without use). Calculate the minimum m that makes it possible and print one possible solution.

The single line of the input contains two space separated integers n, k (1 ≤ n ≤ 10 000, 1 ≤ k ≤ 100).

On the first line print a single integer — the minimal possible m.  On each of the next n lines print four space separated integers representing the i-th set. Neither the order of the sets nor the order of integers within a set is important. If there are multiple possible solutions with minimal m, print any one of them.

NoteFor the first example it's easy to see that set {1, 2, 3, 4} isn't a valid set of rank 1 since .


Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon $$$P$$$ which is defined by coordinates of its vertices. Define $$$P(x,y)$$$ as a polygon obtained by translating $$$P$$$ by vector $$$\overrightarrow {(x,y)}$$$. The picture below depicts an example of the translation:Define $$$T$$$ as a set of points which is the union of all $$$P(x,y)$$$ such that the origin $$$(0,0)$$$ lies in $$$P(x,y)$$$ (both strictly inside and on the boundary). There is also an equivalent definition: a point $$$(x,y)$$$ lies in $$$T$$$ only if there are two points $$$A,B$$$ in $$$P$$$ such that $$$\overrightarrow {AB} = \overrightarrow {(x,y)}$$$. One can prove $$$T$$$ is a polygon too. For example, if $$$P$$$ is a regular triangle then $$$T$$$ is a regular hexagon. At the picture below $$$P$$$ is drawn in black and some $$$P(x,y)$$$ which contain the origin are drawn in colored: The spaceship has the best aerodynamic performance if $$$P$$$ and $$$T$$$ are similar. Your task is to check whether the polygons $$$P$$$ and $$$T$$$ are similar.

The first line of input will contain a single integer $$$n$$$ ($$$3 \le n \le 10^5$$$) — the number of points. The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$x_i, y_i$$$ ($$$|x_i|, |y_i| \le 10^9$$$), denoting the coordinates of the $$$i$$$-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon.

Output "YES" in a separate line, if $$$P$$$ and $$$T$$$ are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower).

NoteThe following image shows the first sample: both $$$P$$$ and $$$T$$$ are squares. The second sample was shown in the statements.

'use strict'

const problem = (n, v) => {
    if (n % 2) return 'NO';
    v.push(v[0]);
    for (let i = 0; i < n/2; i++) {
        if (Math.abs(v[i][0] - v[i+1][0]) !== Math.abs(v[i + n/2][0] - v[i+1 + n/2][0])) return 'NO';
        if (Math.abs(v[i][1] - v[i+1][1]) !== Math.abs(v[i + n/2][1] - v[i+1 + n/2][1])) return 'NO';
    }
    return 'YES';
}
const n = +readline();
const v = Array.from({ length: n }, () => readline().split(' ').map(i => +i))
print(problem(n, v))


The city where Mocha lives in is called Zhijiang. There are $$$n+1$$$ villages and $$$2n-1$$$ directed roads in this city. There are two kinds of roads:  $$$n-1$$$ roads are from village $$$i$$$ to village $$$i+1$$$, for all $$$1\leq i \leq n-1$$$.  $$$n$$$ roads can be described by a sequence $$$a_1,\ldots,a_n$$$. If $$$a_i=0$$$, the $$$i$$$-th of these roads goes from village $$$i$$$ to village $$$n+1$$$, otherwise it goes from village $$$n+1$$$ to village $$$i$$$, for all $$$1\leq i\leq n$$$. Mocha plans to go hiking with Taki this weekend. To avoid the trip being boring, they plan to go through every village exactly once. They can start and finish at any villages. Can you help them to draw up a plan?

Each test contains multiple test cases.  The first line contains a single integer $$$t$$$ ($$$1 \le t \le 20$$$) — the number of test cases. Each test case consists of two lines. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^4$$$) — indicates that the number of villages is $$$n+1$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 1$$$). If $$$a_i=0$$$, it means that there is a road from village $$$i$$$ to village $$$n+1$$$. If $$$a_i=1$$$, it means that there is a road from village $$$n+1$$$ to village $$$i$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^4$$$.

For each test case, print a line with $$$n+1$$$ integers, where the $$$i$$$-th number is the $$$i$$$-th village they will go through. If the answer doesn't exist, print $$$-1$$$. If there are multiple correct answers, you can print any one of them.

NoteIn the first test case, the city looks like the following graph:So all possible answers are $$$(1 \to 4 \to 2 \to 3)$$$, $$$(1 \to 2 \to 3 \to 4)$$$.In the second test case, the city looks like the following graph:So all possible answers are $$$(4 \to 1 \to 2 \to 3)$$$, $$$(1 \to 2 \to 3 \to 4)$$$, $$$(3 \to 4 \to 1 \to 2)$$$, $$$(2 \to 3 \to 4 \to 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--) {
		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);
	}
}

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

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

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


It's a very unfortunate day for Volodya today. He got bad mark in algebra and was therefore forced to do some work in the kitchen, namely to cook borscht (traditional Russian soup). This should also improve his algebra skills.According to the borscht recipe it consists of n ingredients that have to be mixed in proportion  litres (thus, there should be a1 ·x, ..., an ·x litres of corresponding ingredients mixed for some non-negative x). In the kitchen Volodya found out that he has b1, ..., bn litres of these ingredients at his disposal correspondingly. In order to correct his algebra mistakes he ought to cook as much soup as possible in a V litres volume pan (which means the amount of soup cooked can be between 0 and V litres). What is the volume of borscht Volodya will cook ultimately?

The first line of the input contains two space-separated integers n and V (1 ≤ n ≤ 20, 1 ≤ V ≤ 10000). The next line contains n space-separated integers ai (1 ≤ ai ≤ 100). Finally, the last line contains n space-separated integers bi (0 ≤ bi ≤ 100).

Your program should output just one real number — the volume of soup that Volodya will cook. Your answer must have a relative or absolute error less than 10 - 4.

'use strict'

let lll = readline().split(' ').map(v => parseInt(v))
let N = lll[0]
let V = lll[1]
let as = readline().split(' ').map(v => parseInt(v))
let bs = readline().split(' ').map(v => parseInt(v))

let p = as.reduce((r, v) => r + v, 0)
let ds = bs.map((b, i) => b / as[i] * p)
let s = ds.reduce((r, d) => Math.min(r, d), Infinity)
print(Math.min(s, V))


This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You may also refer to the guide on interactive problems: https://codeforces.com/blog/entry/45307.The jury guessed some array $$$a$$$ consisting of $$$6$$$ integers. There are $$$6$$$ special numbers — $$$4$$$, $$$8$$$, $$$15$$$, $$$16$$$, $$$23$$$, $$$42$$$ — and each of these numbers occurs in $$$a$$$ exactly once (so, $$$a$$$ is some permutation of these numbers).You don't know anything about their order, but you are allowed to ask up to $$$4$$$ queries. In each query, you may choose two indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le 6$$$, $$$i$$$ and $$$j$$$ are not necessarily distinct), and you will get the value of $$$a_i \cdot a_j$$$ in return.Can you guess the array $$$a$$$?The array $$$a$$$ is fixed beforehand in each test, the interaction program doesn't try to adapt to your queries.

NoteIf you want to submit a hack for this problem, your test should contain exactly six space-separated integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_6$$$. Each of $$$6$$$ special numbers should occur exactly once in the test. The test should be ended with a line break character.

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

}());


You are given a positive integer $$$n$$$. You have to find $$$4$$$ positive integers $$$a, b, c, d$$$ such that  $$$a + b + c + d = n$$$, and $$$\gcd(a, b) = \operatorname{lcm}(c, d)$$$.If there are several possible answers you can output any of them. It is possible to show that the answer always exists.In this problem $$$\gcd(a, b)$$$ denotes the greatest common divisor of $$$a$$$ and $$$b$$$, and $$$\operatorname{lcm}(c, d)$$$ denotes the least common multiple of $$$c$$$ and $$$d$$$.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Description of the test cases follows. Each test case contains a single line with integer $$$n$$$ ($$$4 \le n \le 10^9$$$) — the sum of $$$a$$$, $$$b$$$, $$$c$$$, and $$$d$$$.

For each test case output $$$4$$$ positive integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$ such that $$$a + b + c + d = n$$$ and $$$\gcd(a, b) = \operatorname{lcm}(c, d)$$$.

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