This week Arkady wanted to cook some pancakes (to follow ancient traditions) and make a problem about that. But then he remembered that one can't make a problem about stacking pancakes without working at a specific IT company, so he decided to bake the Napoleon cake instead.To bake a Napoleon cake, one has to bake $$$n$$$ dry layers first, and then put them on each other in one stack, adding some cream. Arkady started with an empty plate, and performed the following steps $$$n$$$ times:   place a new cake layer on the top of the stack;  after the $$$i$$$-th layer is placed, pour $$$a_i$$$ units of cream on top of the stack. When $$$x$$$ units of cream are poured on the top of the stack, top $$$x$$$ layers of the cake get drenched in the cream. If there are less than $$$x$$$ layers, all layers get drenched and the rest of the cream is wasted. If $$$x = 0$$$, no layer gets drenched.  The picture represents the first test case of the example. Help Arkady determine which layers of the cake eventually get drenched when the process is over, and which don't.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 20\,000$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of layers in the cake. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le n$$$) — the amount of cream poured on the cake after adding each layer. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print a single line with $$$n$$$ integers. The $$$i$$$-th of the integers should be equal to $$$1$$$ if the $$$i$$$-th layer from the bottom gets drenched, and $$$0$$$ otherwise.

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      cream[i] = 0;
      if (a[i] === 0) {
         continue;
      }
      var bottom = i - a[i] + 1;
      if (bottom < 0) {
         bottom = 0;
      }
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   MEMORY = fs.readFileSync(inTextName ? require('path').join(__dirname, inTextName) : 0, 'utf8').split('\r\n');
   init();
} else {
   init();
}

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      cream[i] = 0;
      if (a[i] === 0) {
         continue;
      }
      var bottom = i - a[i] + 1;
      if (bottom < 0) {
         bottom = 0;
      }
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   MEMORY = fs.readFileSync(inTextName ? path.join(__dirname, inTextName) : 0, 'utf8').split('\r\n');
   init();
} else {
   init();
}

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      cream[i] = 0;
      if (a[i] === 0) {
         continue;
      }
      var bottom = i - a[i] + 1;
      if (bottom < 0) {
         bottom = 0;
      }
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   fs.readFile(inTextName ? path.join(__dirname, inTextName) : 0, 'utf8', function(err, data) {
      MEMORY = data.split('\r\n');
      init();
   });
} else {
   init();
}

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    const res = Array(n).fill(0)
    for (let i = n - 1; i >= 0; i--) {
        if (arr[i] !== 0) {
            res[i] = 1
            if (arr[i - 1] < arr[i]) arr[i - 1] = arr[i] - 1
        }
    }
    console.log(res.join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) solve(inputArr[i][0], inputArr[i + 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));

const INF = 2e5+1;

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

		const ans = [];
		for (let i = n - 1, mn = INF; i >= 0; i--) {
			mn = Math.min(mn, i - a[i] + 1);
			ans[i] = i >= mn ? 1 : 0;
		}

		console.log(ans.join(' '));
	}
}

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

		const st = [];
		for (let i = 0; i < n; i++) {
			if (a[i] == 0) {
				st.push(i);
			} else {
				while (st.length && i - a[i] < st[st.length-1]) {
					st.pop();
				}
			}
		}

		const ans = Array(n).fill(1);
		while (st.length) {
			ans[st.pop()] = 0;
		}

		console.log(ans.join(' '));
	}
}

const { EOL } = require('os');

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

function getAnswer(c) {
  const creams = c.reverse();
  let size = 0;
  for (let i = 0; i < creams.length; i++) {
    if (creams[i] > size) size = creams[i];
    creams[i] = size > 0 ? 1 : 0;
    size--;
  }
  return c.reverse().join(' ');
}

function main(param) {
  const input = param.split(EOL);
  const t = Number(input[0]);
  let index = 1;
  for (let i = 0; i < t; i++) {
    index++;
    const creams = input[index++].split(/\s+/).map(Number);
    console.log(getAnswer(creams));
  }
}

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 a = lines[i].split(' ').map(Number);
            var temp = a[n - 1];
            var b = new Array(n);
            for(j = 0; j < n; j++){
                b[j] = 0;
            }
            for(j = n - 1; j >= 0; j--){
                if(temp !== 0 || a[j] !== 0){
                    b[j] = 1;
                    temp = Math.max(temp, a[j]);
                    temp--;
                }else{
                    temp = a[j];
                }
            }
            var ans = '';
            for(j = 0; j < n; j++){
                ans += b[j] + ' ';
            }
            console.log(ans);
        }
    }
});

'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();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
  const x = readline();

  Array(parseInt(x)).fill(1).map((t, iii) => {
    var n = parseInt(readline())

    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    })

    var max = 0
    var ans = new Array(n).fill(0)
    for (let i = n; i >= 0; i--) {
      if (a[i] > 0 && a[i] > max-1) {
        max = a[i]
        ans[i] = 1
        max--
        continue
      }
      if (max > 0) {
        ans[i] = 1
        max--
      }

    }

    // if(n>=1) ans-=a[n-1]

    console.log(ans.join(' '))
    // console.log(a)

  })
}

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

  return gcd(b, a % b);
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		var queue = [];
		for(var j = 0; j < N; j++){
			queue.push(0);
			if(list[j] != 0){
				if(queue.length > list[j]){
					queue[j - list[j] + 1] = list[j];
				}else{
					queue[0] = queue.length;
				}
			}
		}

		var last = -1;
		for(var j = 0; j < N; j++){
			if(queue[j] != 0){
				last = Math.max(last, queue[j]);
			}
			if(last > 0){
				queue[j] = 1;
				last--;
			}
		}
		myout(myconv(queue, 8));
	}
}

function solve() {
  var numPan = readline("");
  var array = readline("").split(" ");

  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length-1;ab>=0;ab--) {
    print(ans[ab]);
  }
  return "hi";
}

var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}

var input = parseInt(readline());

for (var z = 0; z < input; z++) {
    var pies = parseInt(readline());
    var cr = readline()
    .split(" ")
    .map((x) => parseInt(x));
    var dt = pies, ndt;
    for(var i =pies-1;i>=0;i--)
    {
        if(cr[i])
        {
            if(cr[i] > i+1)
            {
                cr[i] = i+1;
            }
            if(dt > (i - cr[i]+1))
            {
                dt = i - cr[i] + 1;
            }
        }

        if(i>=dt)
        {
            cr[i]=1;
        }
        else
        {
            cr[i]=0
        }
    //   print(dt)
    }
    var str="";
     for(var i =0;i<pies;i++)
     {
         str += cr[i]+" "
     }
     print(str)
    }

var input = parseInt(readline());

for (var z = 0; z < input; z++) {
    var pies = parseInt(readline());
    var cr = readline()
    .split(" ")
    .map((x) => parseInt(x));
    var dt = pies, ndt;
    for(var i =pies-1;i>=0;i--)
    {
        if(cr[i])
        {
            if(cr[i] > i+1)
            {
                cr[i] = i+1;
            }
            if(dt > (i - cr[i]+1))
            {
                dt = i - cr[i] + 1;
            }
        }

        if(i>=dt)
        {
            cr[i]=1;
        }
        else
        {
            cr[i]=0
        }
    //   print(dt)
    }
    var str="";
     for(var i =0;i<pies;i++)
     {
         str += cr[i]+" "
     }
     print(str)
//   var n = params[0];
//   var m = params[1];
//   var k = params[2];
//   var graph = [];
//   var vertLen = [];

//   print(vertLen);
//   for (var i = 0; i < m; i++) {
//     var verts = readline()
//       .split(" ")
//       .map((x) => parseInt(x));
//     var a = verts[0];
//     var b = verts[1];
//     if (!graph[a]) {
//       graph[a] = [];
//       graph[a].fill(0);
//       vertLen[a] = 0;
//     }
//     if (!graph[b]) {
//       graph[b] = [];
//       graph[b].fill(0);
//       vertLen[b] = 0;
//     }
//     graph[a][b] = 1;
//     graph[b][a] = 1;
//     vertLen[a] += 1;
//     vertLen[b] += 1;
//   }

//   var vertToDel = [];

// //   print(vertLen);

//   var r = 0;
//   while (
//     vertLen.map((x, index) => {
//       if (x < k - 1 && x != -1) vertToDel.push(index);
//     }) &&
//     vertToDel.length > 0
//   ) {
//     r++;
//     // print("entered", vertToDel, "-", vertLen);
//     for (var i = 0; i < vertToDel.length; i++) {
//       var vert = vertToDel[i];
//       graph.map((x, index) => {
//         if (x.length > 0) {
//           if (graph[index][vert] === 1) {
//             graph[index][vert] = 0;
//             vertLen[index] = vertLen[index] - 1;
//           }
//         }
//       });
//       graph[vert] = [];
//       vertLen[vert] = -1;
//     }
//     vertToDel = [];
//   }

//   var ind = 0;
//   graph.map((x, index) => {
//     if (x.length > 0) {
//       ind = index;
//     }
//   });

//     if(ind===0)
//     {
//         print('-1');
//         continue;
//     }
//   var subset = [];
//   var level1 = [ind];
//   var level2 = [];
//   subset = subset.concat(level1);

//   while (level1.length > 0) {
//       print(subset);
//     level1.forEach((x, index) => {
//       if (graph[x].length > 0) {
//       graph[x].map((x,index)=>{
//           if(x===1 && !subset.includes(index) && !level2.includes(index))
//           {
//               level2.push(index);
//           }
//       })
//       }
//     });
//     subset = subset.concat(level2);
//     level1= [].concat(level2);
//     level2 = [];
//   }
//   print(subset);
}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      cream[i] = 0;
      if (a[i] === 0) {
         continue;
      }
      var bottom = i - a[i] + 1;
      if (bottom < 0) {
         bottom = 0;
      }
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', function(err, data) {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var readable = process.stdin;
      readable.once('readable', function() {
         MEMORY = ('' + readable.read()).split('\r\n');
         init();
      });
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function getInt(num){
        return parseInt(num, 10);
    }
var t = parseInt(readline(), 10);
for(var it = 0; it<t; it++){
    var n = parseInt(readline(), 10);

    var line = readline().split(' ').map(getInt);
    var counter = 0;
    var result = [];
    for(var i = n - 1; i >=0; i--){
        counter = Math.max(line[i], counter);
        var res = counter > 0? 1 : 0;
        counter --;

        result.push(res);

    }

    print(result.reverse().join(' '))

}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      cream[i] = 0;
      if (a[i] === 0) {
         continue;
      }
      var bottom = i - a[i] + 1;
      if (bottom < 0) {
         bottom = 0;
      }
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var readable = process.stdin;
      readable.once('readable', function() {
         MEMORY = ('' + readable.read()).split('\r\n');
         init();
      });
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      if (!a[i]) {
         cream[i] = 0;
         continue;
      }
      var bottom = Math.max(0, i - a[i] + 1);
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var readable = process.stdin;
      readable.once('readable', function() {
         MEMORY = ('' + readable.read()).split('\r\n');
         init();
      });
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = a.map(x => 0);
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      if (!a[i]) {
         continue;
      }
      var bottom = Math.max(0, i - a[i] + 1);
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var readable = process.stdin;
      readable.once('readable', function() {
         MEMORY = ('' + readable.read()).split('\r\n');
         init();
      });
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    for (let i = n-1; i >= 0; i--) {
        let count = arr[i]
        if(count === 0) continue
        for (let j = 0; j < count; j++) {
            if ((i - j) < 0) break
            arr[i - j] = 1
        }
        i -= (count-1)
    }
    console.log(arr.join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) {
        solve(inputArr[i][0], inputArr[i + 1])
    }
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    for (let i = n-1; i >= 0; i--) {
        let count = arr[i]
        for (let j = 0; j < count; j++) {
            if ((i - j) < 0) break
            arr[i - j] = 1
        }
        i -= count
    }
    console.log(arr.join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) {
        solve(inputArr[i][0], inputArr[i + 1])
    }
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    const res = Array(n).fill(0)
    for (let i = n; i !== 0; i--) {
        for (let j = 0; j < arr[i]; j++) {
            res[i - j] = 1
        }
    }
    console.log(res.join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) {
        solve(inputArr[i][0], inputArr[i + 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;
}

function main () {

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

		let ans = Array(n).fill(0);
		for (let i = n - 1, k = 0; i >= 0; i--) {
			k = Math.max(k, a[i]);
			if (k) { ans[i] = 1; k--; }
		}

		console.log(ans.join(' '));
	}

}

function solve() {
  var numPan = readline("");
  var array = readline("").split(" ");

  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length;ab>=0;ab--) {
    print(ans[ab]);
  }
  return "hi";
}

function test() {
var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}
return "hello";
}
test();

function solve() {
  var numPan = readline("");
  var array = readline("").split(" ");

  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length;ab>=0;ab--) {
    print(ans[ab]);
  }
  return "hi";
}

var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}

function solve() {
  var numPan = readline("");
  var array = readline("").split(" ");

  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length;ab>=0;ab--) {
    print(ans[ab]);
  }
  return;
}

var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}

function solve() {
  var numPan = readline("");
  var array = readline("").split(" ");

  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length;ab>=0;ab--) {
    print(ans[ab]);
  }
}

var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}

function solve() {
  var numPan = readline("");
  var array = [];
  for (var i=0;i<numPan;i++) {
    var e = readline("");
    array.push(e);
  }
  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length;ab>=0;ab--) {
    print(ans[ab]);
  }
}

var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}

var input = parseInt(readline());

for (var z = 0; z < input; z++) {
    var pies = parseInt(readline());
    var cr = readline()
    .split(" ")
    .map((x) => parseInt(x));
    var dt = pies, ndt;
    for(var i =pies-1;i>=0;i--)
    {
        if(cr[i])
        {
            if(cr[i] > i+1)
            {
                cr[i] = i+1;
            }
            if(dt > (i - cr[i]+1))
            {
                dt = i - cr[i] + 1;
            }
        }

        if(i>=dt)
        {
            cr[i]=1;
        }
        else
        {
            cr[i]=0
        }
    //   print(dt)
    }
    print(cr);
//   var n = params[0];
//   var m = params[1];
//   var k = params[2];
//   var graph = [];
//   var vertLen = [];

//   print(vertLen);
//   for (var i = 0; i < m; i++) {
//     var verts = readline()
//       .split(" ")
//       .map((x) => parseInt(x));
//     var a = verts[0];
//     var b = verts[1];
//     if (!graph[a]) {
//       graph[a] = [];
//       graph[a].fill(0);
//       vertLen[a] = 0;
//     }
//     if (!graph[b]) {
//       graph[b] = [];
//       graph[b].fill(0);
//       vertLen[b] = 0;
//     }
//     graph[a][b] = 1;
//     graph[b][a] = 1;
//     vertLen[a] += 1;
//     vertLen[b] += 1;
//   }

//   var vertToDel = [];

// //   print(vertLen);

//   var r = 0;
//   while (
//     vertLen.map((x, index) => {
//       if (x < k - 1 && x != -1) vertToDel.push(index);
//     }) &&
//     vertToDel.length > 0
//   ) {
//     r++;
//     // print("entered", vertToDel, "-", vertLen);
//     for (var i = 0; i < vertToDel.length; i++) {
//       var vert = vertToDel[i];
//       graph.map((x, index) => {
//         if (x.length > 0) {
//           if (graph[index][vert] === 1) {
//             graph[index][vert] = 0;
//             vertLen[index] = vertLen[index] - 1;
//           }
//         }
//       });
//       graph[vert] = [];
//       vertLen[vert] = -1;
//     }
//     vertToDel = [];
//   }

//   var ind = 0;
//   graph.map((x, index) => {
//     if (x.length > 0) {
//       ind = index;
//     }
//   });

//     if(ind===0)
//     {
//         print('-1');
//         continue;
//     }
//   var subset = [];
//   var level1 = [ind];
//   var level2 = [];
//   subset = subset.concat(level1);

//   while (level1.length > 0) {
//       print(subset);
//     level1.forEach((x, index) => {
//       if (graph[x].length > 0) {
//       graph[x].map((x,index)=>{
//           if(x===1 && !subset.includes(index) && !level2.includes(index))
//           {
//               level2.push(index);
//           }
//       })
//       }
//     });
//     subset = subset.concat(level2);
//     level1= [].concat(level2);
//     level2 = [];
//   }
//   print(subset);
}


You are given two strings $$$s$$$ and $$$t$$$. The string $$$s$$$ consists of lowercase Latin letters and at most one wildcard character '*', the string $$$t$$$ consists only of lowercase Latin letters. The length of the string $$$s$$$ equals $$$n$$$, the length of the string $$$t$$$ equals $$$m$$$.The wildcard character '*' in the string $$$s$$$ (if any) can be replaced with an arbitrary sequence (possibly empty) of lowercase Latin letters. No other character of $$$s$$$ can be replaced with anything. If it is possible to replace a wildcard character '*' in $$$s$$$ to obtain a string $$$t$$$, then the string $$$t$$$ matches the pattern $$$s$$$.For example, if $$$s=$$$"aba*aba" then the following strings match it "abaaba", "abacaba" and "abazzzaba", but the following strings do not match: "ababa", "abcaaba", "codeforces", "aba1aba", "aba?aba".If the given string $$$t$$$ matches the given string $$$s$$$, print "YES", otherwise print "NO".

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$ and the length of the string $$$t$$$, respectively. The second line contains string $$$s$$$ of length $$$n$$$, which consists of lowercase Latin letters and at most one wildcard character '*'. The third line contains string $$$t$$$ of length $$$m$$$, which consists only of lowercase Latin letters.

Print "YES" (without quotes), if you can obtain the string $$$t$$$ from the string $$$s$$$. Otherwise print "NO" (without quotes).

NoteIn the first example a wildcard character '*' can be replaced with a string "force". So the string $$$s$$$ after this replacement is "codeforces" and the answer is "YES".In the second example a wildcard character '*' can be replaced with an empty string. So the string $$$s$$$ after this replacement is "vkcup" and the answer is "YES".There is no wildcard character '*' in the third example and the strings "v" and "k" are different so the answer is "NO".In the fourth example there is no such replacement of a wildcard character '*' that you can obtain the string $$$t$$$ so the answer is "NO".

readline();
var str = readline();
var a = str.split('*');
var b = readline();
if (b.substring(0,a[0].length) === a[0] && ((a.length == 2)?(b.substring(b.length-a[1].length,b.length) === a[1]) && str.length-1<=b.length:str.length === b.length)){
    print('YES')
}else{
    print('NO')
}

var lengths = readline();

var length1 = parseInt(lengths.split(" ")[0])
var length2 = parseInt(lengths.split(" ")[1])

var string = readline();
var string1 = readline();
var p = false;

print(check());

function check() {
    if (length1 >= length2 + 2) {
        return "NO";
    }

    for (var i = 0; i < length1; i++) {
        if (string[i] === "*") {
            p = true;
            break;
        }
        if (string1[i] !== string[i]) {
            return "NO";
        }
    }

    for (var i = 0; i < length1; i++) {
        if (string[length1-i] === "*") {
            p = true;
            break;
        }
        if (string1[length2-i] !== string[length1-i]) {
            return "NO";
        }
    }

    if (!p && length1 !== length2) {
        return "NO";
    }

    return "YES";
}

function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray(Number);
  const s = is.nextLine();
  const t = is.nextLine();

  const index = s.indexOf('*');
  if (index === -1 || n > m + 1) {
    console.log(s === t ? 'YES' : 'NO');
  } else {
    const left = s.substr(0, index);
    const right = s.substr(index + 1, s.length);
    let tReverse = t.slice();
    tReverse = tReverse.split('').reverse().slice(0, right.length).reverse().join('');
    if (left === t.substr(0, left.length) && right === tReverse) {
      console.log('YES');
    } else {
      console.log('NO');
    }
  }

}

/*
 *  Api Scanner
 */
class Scanner {
  constructor() {
    this.index = -1;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    this.index += 1;
    return this.lines[this.index].trim();
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray(fn) {
    const array = this.nextLine().split(' ');
    return fn === String ? array : array.map(fn);
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

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

var str0 = ""
var str1 = ""

var c = 0;
rl.on('line', function (line) {
    c += 1;
    if (c == 2) {
        str0 = line;
    }
    else if (c == 3) {
        str1 = line;
        rl.close();
        console.log(isOk() ? "YES" : "NO");
    }
});

function isOk() {
    if (str0.indexOf("*") == -1) {
        if (str0!=str1) {return false}
    }
    var tCs = str0.split("");
    var fCs = str1.split("");
    var index = 0;
    var sBefore = ""; iStart = 0; iPos = 0;
    while (index < str0.length) {
        if (tCs[index]!="*") {
            sBefore += tCs[index];
        }
        else {
            if (str1.indexOf(sBefore, iPos)!=iStart) {
                return false;
            }
            iPos = sBefore.length;
            sBefore = "";
            jIndex = index + 1;
            while (tCs[jIndex]!="*" && jIndex < str0.length) {
                sBefore += tCs[jIndex];
                jIndex += 1;
            }
            iStart = str1.indexOf(sBefore, iPos);
            if (iStart==-1) {
                return false
            }
            index = jIndex - 1;
            if (index==str0.length-1) {
               if (!(str0[index]=="*" || str0[index]==fCs[str1.length-1])) {
                   return false
                }
            }
        }
        index += 1;
    }
    return true;
}

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

var templateString = ""
var testString = ""

var c = 0;
rl.on('line', function (line) {
    c += 1;
    if (c == 2) {
        templateString = line;
    }
    else if (c == 3) {
        testString = line;
        rl.close();
        console.log(isOk() ? "yes" : "no");
    }
});

function isOk() {
    if (templateString.indexOf("*") == -1) {
        if (templateString!=testString) {return false}
    }
    var tCs = templateString.split("");
    var fCs = testString.split("");
    var index = 0;
    var sBefore = ""; iStart = 0; iPos = 0;
    while (index < templateString.length) {
        if (tCs[index]!="*") {
            sBefore += tCs[index];
        }
        else {
            if (testString.indexOf(sBefore, iPos)!=iStart) {
                return false;
            }
            iPos = sBefore.length;
            sBefore = "";
            jIndex = index + 1;
            while (tCs[jIndex]!="*" && jIndex < templateString.length) {
                sBefore += tCs[jIndex];
                jIndex += 1;
            }
            iStart = testString.indexOf(sBefore, iPos);
            if (iStart==-1) {
                return false
            }
            index = jIndex - 1;
            if (index==templateString.length-1) {
               if (!(templateString[index]=="*" || templateString[index]==fCs[testString.length-1])) {
                   return false
                }
            }
        }
        index += 1;
    }
    return true;
}

readline();
var str = readline();
var a = str.split('*');
var b = readline();
if (b.indexOf(a[0]) === 0 && ((a.length == 2)?(b.lastIndexOf(a[1])+a[1].length === b.length)&&str.length-1<=b.length:true)){
    print('YES')
}else{
    print('NO')
}

var lengths = readline();

var length1 = parseInt(lengths.split(" ")[0])
var length2 = parseInt(lengths.split(" ")[1])

var string = readline();
var string1 = readline();

print(check());

function check() {
    if (length1 > length2 + 2) {
        return "NO";
    }

    for (var i = 0; i < length1; i++) {
        if (string[i] === "*") {
            break;
        }
        if (string1[i] !== string[i]) {
            return "NO";
        }
    }

    for (var i = 0; i < length1; i++) {
        if (string[length1-i] === "*") {
            break;
        }
        if (string1[length2-i] !== string[length1-i]) {
            return "NO";
        }
    }

    return "YES";
}

var lengths = readline();

var length1 = parseInt(lengths.split(" ")[0])
var length2 = parseInt(lengths.split(" ")[1])

var string = readline();
var string1 = readline();

print(check());

function check() {
    if (length1 >= length2 + 2) {
        return "NO";
    }

    for (var i = 0; i < length1; i++) {
        if (string[i] === "*") {
            break;
        }
        if (string1[i] !== string[i]) {
            return "NO";
        }
    }

    for (var i = 0; i < length1; i++) {
        if (string[length1-i] === "*") {
            break;
        }
        if (string1[length2-i] !== string[length1-i]) {
            return "NO";
        }
    }

    return "YES";
}

var lengths = readline();

var length1 = parseInt(lengths.split(" ")[0])
var length2 = parseInt(lengths.split(" ")[1])

var string = readline();
var string1 = readline();

print(check());

function check() {
    if (length1 > length2 + 2) {
        return "NO";
    }

    for (var i = 0; i < length1; i++) {
        if (string[i] === "*") {
            break;
        }
        if (string1[i] !== string[i]) {
            print(string1[i] + ' 2  ' + string[i])
            return "NO";
        }
    }

    for (var i = 0; i < length1; i++) {
        if (string[length1-i] === "*") {
            break;
        }
        if (string1[length2-i] !== string[length1-i]) {
            print(string1[length2-i] + ' 4  ' + string[length1-i])
            return "NO";
        }
    }

    return "YES";
}

var lengths = readline();

var length1 = parseInt(lengths.split(" ")[0])
var length2 = parseInt(lengths.split(" ")[1])

var string = readline();
var string1 = readline();

print(check());

function check() {
    if (length1 > length2 + 2) {
        return "NO";
    }

    for (var i = 0; i < length1; i++) {
        if (string[i] === "*") {
            break;
        }
        if (string1[i] !== string[i]) {
            print(string1[i] + ' 2  ' + string[i])
            return "NO";
        }
    }

    for (var i = 0; i < length1; i++) {
        if (string[length1-i] === "*") {
            break;
        }
        if (string1[length2-i] !== string[length1-i]) {
            return "NO";
        }
    }

    return "YES";
}

function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray(Number);
  const s = is.nextLine();
  const t = is.nextLine();

  const index = s.indexOf('*');
  if (index === -1) {
    console.log(s === t ? 'YES' : 'NO');
  } else {
    const left = s.substr(0, index);
    const right = s.substr(index + 1, s.length);
    let tReverse = t.slice();
    tReverse = tReverse.split('').reverse().slice(0, right.length).reverse().join('');
    if (left === t.substr(0, left.length) && right === tReverse) {
      console.log('YES');
    } else {
      console.log('NO');
    }
  }

}

/*
 *  Api Scanner
 */
class Scanner {
  constructor() {
    this.index = -1;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    this.index += 1;
    return this.lines[this.index].trim();
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray(fn) {
    const array = this.nextLine().split(' ');
    return fn === String ? array : array.map(fn);
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

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

var str0 = ""
var str1 = ""

var c = 0;
rl.on('line', function (line) {
    c += 1;
    if (c == 2) {
        str0 = line;
    }
    else if (c == 3) {
        str1 = line;
        rl.close();
        console.log(isOk() ? "YES" : "NO");
    }
});

function isOk() {
    if (str0.indexOf("*") == -1) {
        if (str0!=str1) {return false}
    }
    var tCs = str0.split("");
    var fCs = str1.split("");
    var index = 0;
    var sBefore = ""; iStart = 0; iPos = 0;
    while (index < str0.length) {
        if (tCs[index]!="*") {
            sBefore += tCs[index];
        }
        else {
            if (str1.indexOf(sBefore, iPos)!=iStart) {
                return false;
            }
            iPos = sBefore.length;
            sBefore = "";
            jIndex = index + 1;
            while (tCs[jIndex]!="*" && jIndex < str0.length) {
                sBefore += tCs[jIndex];
                jIndex += 1;
            }
            iStart = str1.indexOf(sBefore, iPos);
            if (iStart==-1) {
                return false
            }
            index = jIndex - 1;
            if (index==str0.length-1) {
               if (!(str0[index]=="*" || str0[index]==fCs[str1.length-1])) {
                   return false
                }
            }
        }
        index += 1;
    }
    console.log(sBefore);

    return true;
}


Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \dfrac{x}{f(f(x))}$$$ ($$$x$$$ is a positive integer as well).Your task is the following: for the given positive integer $$$n$$$, calculate the number of different values of $$$g(x)$$$ among all numbers $$$x$$$ such that $$$1 \le x \le n$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n < 10^{100}$$$). This integer is given without leading zeroes.

For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.

NoteExplanations for the two first test cases of the example:  if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$;  if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)) = 23$$$,$$$\dfrac{x}{f(f(x))} = 1$$$); and for other values of $$$x$$$, $$$\dfrac{x}{f(f(x))} = 10$$$ (for example, if $$$x = 30$$$, $$$f(f(x)) = 3$$$, $$$\dfrac{x}{f(f(x))} = 10$$$). So, there are two different values of $$$g(x)$$$.

'use strict'

let t = readline();

while(t--)
{
    let n = readline();
    print(n.length);
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var l = readline();

  print(l.length);
}

var tc = parseInt(readline());
for (; tc--;){
    var s = readline();
    print(s.length);
}

function task(input){
	let ia = input.trim().split('\n');
	let t = +ia.shift();
	for (let i = 0; i < t; i++) {
		let n = ia.shift().trim()
		let x = n.length
		console.log(x)
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', _ => {
    task(inputString);
});

const solve = (n) => {
    console.log(n.length);
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line);
    });
    rl.on('close', () => {
        let t = Number(input[0]);
        let i = 1;
        while (t > 0) {
            solve(input[i]);
            t--;
            i++;
        }
    });
};

main()

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

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  let t = +readLine();
  while (t--) {
    const n = readLine();
    console.log(n.length);
  }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){outputList.push(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();
	for(var i = 0; i < t; i++){
		var N = next();
		var count = N.length;
		/*if(N[N.length - 1] == "0"){
			count++;
		}*/
		myout(count);
	}
}

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

  let i = 1;
  let t = 0;
  readline.on('line', line => {
    if (i == 1) {
        // number of test case
        t = parseInt(line)
        i++;
    } else if (i <= t) {
        solve(line)
        i++;
    } else {
        solve(line)
        readline.close()
    }
  });

  function solve(input) {
      console.log(input.length)
  }

function run(sol) {
  let i = ''
  process.stdin.on('data', c => i += c)
  process.stdin.on('end', () => {
      const {EOL} = require('os')
      const inputs = i.split(EOL)
      sol(inputs)
  })
}

function solution(inputs) {
  const t = Number(inputs[0])
  for (let i = 1; i <= t; ++i) {
    console.log(inputs[i].length)
  }

}

run(solution)

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

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

// import './array'
//
// import io from './io'
//
// function main() {
//   let s = io.readline()
//
//   io.puts(s.length)
// }
//
// io.runEachTest(main)
// // io.runMain(main)

/*
 * File Created: Monday, 30th November 2020 3:31:00 pm
 * Author: Lukas Rimkus
 */

'use-strict'

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

let data = '';
let currentLine = 0;

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

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const n = data.shift();

        const res = a(n);

        console.log(res)
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

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

function a(num)
{
    return num.length ;
}

module.exports = a;

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function main() {
  const x = readline();
  var answer = []

  Array(Number(x)).fill(1).map((t, i)=>{
    var line = readline();
    console.log(line.length)
  })

}

function task(input){
	let ia = input.trim().split('\n');
	let t = +ia.shift();
	for (let i = 0; i < t; i++) {
		let n = ia.shift()
		console.log(n.length)
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', _ => {
    task(inputString);
});

function task(input){
	let ia = input.trim().split('\n');
	let t = +ia.shift();
	for (let i = 0; i < t; i++) {
		let n = ia.shift()
		let x = n.length
		console.log(x)
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', _ => {
    task(inputString);
});

function task(input){
	let ia = input.trim().split('\n');
	let t = +ia.shift();
	for (let i = 0; i < t; i++) {
		let n = ia.shift()
		console.log([...n].length)
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', _ => {
    task(inputString);
});

const solve = (n) => {
    console.log(n.length);
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line);
    });
    rl.on('close', () => {
        let t = Number(input[0][0]);
        let i = 1;
        while (t > 0) {
            solve(input[i]);
            t--;
            i++;
        }
    });
};

main()


$$$n$$$ heroes fight against each other in the Arena. Initially, the $$$i$$$-th hero has level $$$a_i$$$.Each minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it is the same two heroes that were fighting during the last minute).When two heroes of equal levels fight, nobody wins the fight. When two heroes of different levels fight, the one with the higher level wins, and his level increases by $$$1$$$.The winner of the tournament is the first hero that wins in at least $$$100^{500}$$$ fights (note that it's possible that the tournament lasts forever if no hero wins this number of fights, then there is no winner). A possible winner is a hero such that there exists a sequence of fights that this hero becomes the winner of the tournament.Calculate the number of possible winners among $$$n$$$ heroes.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Each test case consists of two lines. The first line contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of heroes. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$), where $$$a_i$$$ is the initial level of the $$$i$$$-th hero.

For each test case, print one integer — the number of possible winners among the given $$$n$$$ heroes.

NoteIn the first test case of the example, the only possible winner is the first hero.In the second test case of the example, each fight between the heroes results in nobody winning it, so the tournament lasts forever and there is no winner.

var t = readline();
    for(var i = 0 ; i < t ; i++){
        var n = readline(),
            a = readline().split(' ').sort((a,b) => a-b),
            winners = a.filter((hero)=>{
                return hero!= a[0];
            });
            print(winners.length);
    }

var t = readline();
    for(var i = 0 ; i < t ; i++){
        var n = readline(),
            a = readline().split(' ').sort((a,b) => a-b),
            winnrers = a.filter((hero)=>{
                return hero!= a[0];
            });
            print(winnrers.length);
    }

var tests = +readline();
while(tests>0){
    var arrLen = +readline();
    var arr = readline().split(" ").map(x=> parseInt(x));
    arr.sort((a,b)=>a-b);

    var i=0;
    var res = 0;

    while(i<arrLen-1) {
        if(arr[i]<arr[i+1]) {
            res = arrLen-i-1;
            break;
        }
        i++;
    }
    tests--;
    print(res);
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 1;

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels[i] == min) {
            minCount++;
        }
    }
    return arrLevels.length - minCount;
}

//required remainder
let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var a = lines[0];
    var lowest = 0;
    var answer = 0;
    for(var j = 1; j < (Number(a) + 1) * 2; j++){
        lowest = 0;
        answer = 0;
        if(j % 2 === 0){
            var n = lines[j].split(' ').map(Number).sort(function(a, b){return a - b});
            lowest = n[0];
            for(var k = 1; k < n.length; k++){
                if(lowest < n[k]){
                    answer++;
                }
            }
            console.log(answer);
        }
    }
});

function solve(input) {
    // YOUR BUGS HERE...
    res = [];
    input.forEach(e => {
        let a = e[1].split(' ').map(o => parseInt(o));
        let min_a = Math.min(...a);
        let res = a.filter(data => (data - min_a) > 0)
        console.log(res.length);
    });
    // console.log(res.join('\n'));
}

/** =========== DEFAULT FORMAT ==============
 *
 *  */
function set_n_line() {
    // set return 0 if the problem needs dynamic n line inputs
    // set return n > 0 if the problem needs fixed n  line inputs
    return 2
}
const readline = require('readline').createInterface({ input: process.stdin });
let inputs = []; let sub_input = []; let t = 0; let n_line_subinput = set_n_line();
function fillInput(line) {
    // dynamic n_line
    if (n_line_subinput === 0) n_line_subinput = parseInt(line)
    else if (sub_input.length < n_line_subinput) {
        sub_input.push(line)
        if (sub_input.length == n_line_subinput) {
            inputs.push(sub_input); sub_input = [];
            n_line_subinput = set_n_line();
        }
    }
}

readline.on('line', line => {
    if (t === 0) t = parseInt(line)
    else if (inputs.length < t) {
        fillInput(line)
        if (inputs.length == t) { solve(inputs);readline.close() }
    }
});
/* =========== DEFAULT FORMAT END ============== */

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		list.sort(function(a,b){
			return a - b;
		});
		var output = 0;
		for(var j = 0; j < N - 1; j++){
			if(list[j] < list[j + 1]){
				output = N - (j + 1);
				break;
			}
		}
		myout(output);
	}
}

/*
 * File Created: Tuesday, 16th February 2021 2:01:47 pm
 * Author: Lukas Rimkus
 */

 'use-strict'

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

 let data = '';
 let currentLine = 0;

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

 process.stdin.on('end', () =>{
     data = data.replace(/\s*$/, '')
     .split('\n')
     .map(str => str.replace(/\s*$/, ''));

     let testCases = parseInt(data.shift());

     while(testCases--) {

         const l = parseInt(readLine());

         const an = readLine().split(' ').map(Number);

         const res = a(l, an);

         console.log(res)
     }
 });

 function get_ints() {
     return data.shift().split(' ').map(Number);
 }

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

 function a(n,a){
     a.sort((a,b) => a - b);
     let count = 0;
     for(let i = 0 ; i < n; i++){
         if(i === n - 1) break;
         if(a[i] !== a[i+1]){
             return n - i - 1;
         }
     }
     return 0;
 }

module.exports = a;

'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++];
}
/**
2
3 7
24 25 27
10 7
51 52 53 54 55 56 57 58 59 60
**/

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() {
    let n = readline();
    let a = readline().split(" ").map(Number);

    let min = Math.min(...a);

    let count = 0;

    for(let i=0;i<a.length;i++) {
        if(a[i] > min) {
            //console.log(a[i], max);
            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++];
}

function main() {
  const inputs=+readline();

  for(let j = 0; j < inputs; j++) {
    const number_of_heroes = +readline();
    const heroes = readline().split(" ");

    let number_of_values = [];
    heroes.forEach((item, i) => {
      if(+item !== Math.min(...heroes)) number_of_values.push(+item);
    });
    foo(number_of_values.length)
  }

}

const foo = (x) => console.log(x);

'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() {
    var x = Number(readline())
    Array(Number(x)).fill(1).map((t, i) => {
        var n = parseInt(readline())

        var a = readline().split(' ').map((x, i) => {
            return parseInt(x)
        })
        var min = a[0]
        for (var i = 0; i < n; i++) {
            if (a[i] < min) {
                min = a[i]
            }
        }
        var res = n
        for (var i = 0; i < n; i++) {
            if(a[i] === min) res--
        }
        console.log(res)
    })

}

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

    return gcd(b, a % b);
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 0;

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels[i] == min) {
            minCount++;
        }
    }
    return arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 1;

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels == min) {
            minCount++;
        }
    }
    return arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 0;

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels == min) {
            minCount++;
        }
    }
    return arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 0;

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels) {
            minCount++;
        }
    }
    return arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 0;
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels) {
            minCount++;
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        let n = readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - 1;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split().map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    console.log(arrLevels);
    let min = arrLevels[0];
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - 1;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split().map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - 1;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        let arrLevel = readline().split().map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - 1;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let arrLevels = [];
    let testCases = +(readline());
    for (let i = 0; i < testCases.length; i++) {
        readline();
        arrLevels.push(readline().split(" ").map(string => { return parseInt(string) }));
    }
    for (let i = 0; i < arrLevels.length; i++) {
        console.log(getWinners(arrLevels[i]));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - 1;
}

//required remainder
let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var a = lines[0];
    var lowest = 0;
    var answer = 0;
    for(var j = 1; j < (Number(a) + 1) * 2; j++){
        lowest = 0;
        answer = 0;
        if(j % 2 === 0){
            var n = lines[j].split(' ').sort(function(a, b){return a - b});
            lowest = n[0];
            for(var k = 1; k < n.length; k++){
                if(lowest < n[k]){
                    answer++;
                }
            }
            console.log(answer);
        }
    }
});

//required remainder
let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var a = lines[0];
    var lowest = 0;
    var answer = 0;
    for(var j = 1; j < (Number(a) + 1) * 2; j++){
        lowest = 0;
        answer = 0;
        if(j % 2 === 0){
            var n = lines[j].split(' ').sort(function(a, b){return a - b});
            lowest = n[0];
            for(var k = 1; k < n.length + 1; k++){
                if(lowest < n[k]){
                    answer++;
                }else{
                    continue;
                }
            }
            console.log(answer);
        }
    }
});

//required remainder
let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var a = lines[0];
    var lowest = 0;
    var answer = 0;
    for(var j = 1; j < (Number(a) + 1) * 2; j++){
        lowest = 0;
        answer = 0;
        if(j % 2 === 0){
            var n = lines[j].split(' ').sort(function(a, b){return a - b});
            lowest = n[0];
            for(var k = 1; k < n.length + 1; k++){
                if(lowest < n[k]){
                    answer++;
                }
            }
            console.log(answer);
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var k = lines[0];
    var answer = '';
    var a = 0;
    var b = 0;
    for(var j = 1; j < Number(k) + 1; j++){
        var n = lines[j];
        a = 0;
        b = 0;
        answer = '';
        if(n % 4 !== 0){
            console.log('NO');
        }else{
            console.log('YES');
            for(i = 2; i <= n; i += 2){
                answer += i + ' ';
                a += i;
            }
            for(i = 1; i < n - 2; i += 2){
                answer += i + ' ';
                b += i;
            }
            console.log(answer + (a-b));
        }
    }
});

function solve(input) {
    // YOUR BUGS HERE...
    res = [];
    input.forEach(e => {
        let a = e[1].split(' ').map(o => parseInt(o));
        a.sort();
        let res = a.filter(data => (data - a[0]) > 0)
        console.log(res.length);
    });
}

/** =========== DEFAULT FORMAT ==============
 *
 *  */
function set_n_line() {
    return 2
}
const readline = require('readline').createInterface({ input: process.stdin });
let inputs = []; let sub_input = []; let t = 0; let n_line_subinput = set_n_line();
function fillInput(line) {
    // dynamic n_line
    if (n_line_subinput == 0) n_line_subinput = parseInt(line)
    else if (sub_input.length < n_line_subinput) {
        sub_input.push(line)
        if (sub_input.length == n_line_subinput) {
            inputs.push(sub_input); sub_input = [];
            n_line_subinput = set_n_line();
        }
    }
}

readline.on('line', line => {
    if (t == 0) t = parseInt(line)
    else if (inputs.length < t) {
        fillInput(line)
        if (inputs.length == t) { solve(inputs);readline.close() }
    }
});
/* =========== DEFAULT FORMAT END ============== */


A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and ai < aj. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3).You are given a permutation a of size n and m queries to it. Each query is represented by two indices l and r denoting that you have to reverse the segment [l, r] of the permutation. For example, if a = [1, 2, 3, 4] and a query l = 2, r = 4 is applied, then the resulting permutation is [1, 4, 3, 2].After each query you have to determine whether the number of inversions is odd or even.

The first line contains one integer n (1 ≤ n ≤ 1500) — the size of the permutation.  The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ n) — the elements of the permutation. These integers are pairwise distinct. The third line contains one integer m (1 ≤ m ≤ 2·105) — the number of queries to process. Then m lines follow, i-th line containing two integers li, ri (1 ≤ li ≤ ri ≤ n) denoting that i-th query is to reverse a segment [li, ri] of the permutation. All queries are performed one after another.

Print m lines. i-th of them must be equal to odd if the number of inversions in the permutation after i-th query is odd, and even otherwise.

NoteThe first example:  after the first query a = [2, 1, 3], inversion: (2, 1);  after the second query a = [2, 3, 1], inversions: (3, 1), (3, 2). The second example:  a = [1, 2, 4, 3], inversion: (4, 3);  a = [3, 4, 2, 1], inversions: (3, 1), (4, 1), (3, 2), (4, 2), (4, 3);  a = [1, 2, 4, 3], inversion: (4, 3);  a = [1, 4, 2, 3], inversions: (3, 2), (4, 2).

const getInversionsCount = (nums) => {
  var count = 0;

  for (var i = 1; i < nums.length; i++) {
    for (var j = 0; j < i; j++) {
      if (nums[i] < nums[j]) {
        count++;
      }
    }
  }

  return count;
};

const main = () => {
  readline();

  const nums = readline()
    .split(" ")
    .map((i) => Number(i));

  var operationsCount = getInversionsCount(nums);

  const inputCount = Number(readline());

  for (var i = 0; i < inputCount; i++) {
    var input = readline()
      .split(" ")
      .map((i) => Number(i));

    operationsCount += Math.floor((input[1] - input[0] + 1) / 2);

    if (operationsCount % 2 === 0) {
      print("even");
    } else {
      print("odd");
    }
  }
};

main();

// https://en.wikipedia.org/wiki/Parity_of_a_permutation
var line = readline ();
line = line.trim ().split ( ' ' );
var n = line;
var aa = [ ];
line = readline ();
aa = line.trim ().split ( ' ' );
var i, j, cnt = 0;
var a = aa;
a.map ( function ( a ) { return (+ a); } ); // convert array elements to numbers
function merge ( a, b ) {
    var i = 0, j = 0;
    var result = [ ];
    while ( i < a.length && j < b.length ) {
        if ( (+ a [ i ]) < (+ b [ j ]) ) {
            result.push ( a [ i ++ ] );
        } else {
            result.push ( b [ j ++ ] );
            cnt += a.length - i;
        }
    }
    while ( i < a.length ) {
        result.push ( a [ i ++ ] );
    }
    while ( j < b.length ) {
        result.push ( b [ j ++ ] );
        cnt += a.length - i;
    }
    return result;
}
function mergesort ( arr ) {
    var suba = [ ], subb = [ ];
    if ( arr.length > 1 ) {
        suba = mergesort ( arr.slice ( 0, Math.floor ( arr.length / 2 ) ) );
        subb = mergesort ( arr.slice ( Math.floor ( arr.length / 2 ), arr.length ) );
        return merge ( suba, subb );
    }
    return arr;
}
mergesort ( a );
var parity = cnt % 2;
var m = (+ readline ());
var l, r;
for ( var g = 0; g < m; g ++ ) {
    line = readline ();
    line = line.trim ().split ( ' ' );
    l = line [ 0 ];
    r = line [ 1 ];
    if ( Math.ceil ( (r - l) / 2) % 2 == 1 ) parity ^= 1;
    print ( parity ? 'odd' : 'even' );
}

// https://en.wikipedia.org/wiki/Parity_of_a_permutation
var line = readline ();
line = line.trim ().split ( ' ' );
var n = line;
var aa = [ ];
line = readline ();
aa = line.trim ().split ( ' ' );
var i, j, cnt = 0;
for ( i = 0; i < n - 1; i ++ )
    for ( j = i + 1; j < n; j ++ )
        if ( aa [ i ] > aa [ j ] ) cnt ++;
var parity = cnt % 2;
var m = (+ readline ());
var l, r;
for ( var g = 0; g < m; g ++ ) {
    line = readline ();
    line = line.trim ().split ( ' ' );
    l = line [ 0 ];
    r = line [ 1 ];
    if ( Math.ceil ( (r - l) / 2) % 2 == 1 ) parity ^= 1;
    print ( parity ? 'odd' : 'even' );
}