let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, step, fn) {
  let res;
  for (let i = a; i <= b; i += step) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, step, fn, init) {
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++], out = [], log = console.log;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n).sort((a, b) => b - a);
    let c = a[0]
    For(1, n - 1, 1, i => {
      let [, j] = Arr(i, n - 1, 1, j => gcd(c, a[j])).max()
      let temp = a[i];
      a[i] = a[j];
      a[j] = temp;
      c = gcd(c, a[i]);
    });
    console.log(a.join(' '))
  }
})();

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, step, fn) {
  let res;
  for (let i = a; i <= b; i += step) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, step, fn, init) {
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++], out = [], log = console.log;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n).sort((a, b) => b - a);
    let c = a[0]
    For(1, n - 1, 1, i => {
      let [, j] = Arr(i, n - 1, 1, j => gcd(c, a[j])).max();
      [a[i], a[j]] = [a[j], a[i]];
      c = gcd(c, a[i]);
    });
    log(a.join(' '))
  }
})();

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, step, fn) {
  let res;
  for (let i = a; i <= b; i += step) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, step, fn, init) {
  if (!step) {
    return a < b
      ? Array(b - a + 1).fill(0).map((v, i) => fn(a + i))
      : Array(a - b + 1).fill(0).map((v, i) => fn(a - i))
  }
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n).sort(desc);
    let c = a[0]
    For(1, n - 1, 1, i => {
      let j = Arr(i, n - 1, 1, j => gcd(c, a[j])).max()[1];
      [a[i], a[j]] = [a[j], a[i]];
      c = gcd(c, a[i]);
    });
    log(a.join(' '))
  }
})();


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){
	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();
});
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){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var output = new Array();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var map = getPrimeFactorization(N);
		var key = Object.keys(map);
		key.sort(function(a,b){
			return map[b] - map[a];
		});
		var list = [];
		for(var j = 0; j < map[key[0]] - 1; j++){
			list.push(key[0]);
		}
		N /= Math.pow(key[0], map[key[0]] - 1);
		list.push(N);
		output.push(list.length);
		output.push(myconv(list, 8));
	}
	myout(myconv(output, 9));
}
function getPrimeFactorization(val){
  var primeMap = {};
  var div = 2;
  if(isPrime(val)){
    primeMap[val] = 1;
    return primeMap;
  }
  while(val != 1){
    if(val % div == 0){
      var count = 2;
      while(val % Math.pow(div, count) == 0){
         count++;
      }
      (primeMap[div] == null)  ? primeMap[div] = (count - 1) : primeMap[div] += (count - 1);
      val /= Math.pow(div, count - 1);
      if(isPrime(val)){
        (primeMap[val] == null)  ? primeMap[val] = 1 : primeMap[val]++;
        break;
      }
    }
    div = (div == 2) ? div + 1 : div + 2;
  }
  return primeMap;
}
function isPrime(val){
  if(val == null || val <= 1 || (val != 2 && val % 2 == 0)){
    return false;
  }else if(val == 2){
    return true;
  }
  var root = Math.floor(Math.sqrt(val));
  for(var i = 3; i <= root; i += 2){
    if(val % i == 0){
      return false;
    }
  }
  return true;
}

"use strict";

(() => {

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

    let curLine = 0, allLines = [];

    let nextLine = () => {
        if(curLine == allLines.length) throw new ReferenceError("No more input in the buffer");
        return allLines[curLine++]
    };

    readline.on("line", line => { allLines.push(line); });
    readline.on("close", () => { main(nextLine) });

})();

function main(nextLine) {
    let t = Number(nextLine());

    while(t--) {
        let n = Number(nextLine());

        let ans = new Array(40).fill(1);

        for(let i = 2; i*i <= n; i++) {
            if(n%i == 0) {
                for(let j = 0; n%i == 0; j++) ans[j] *= i, n /= i;
            }
        }
        if(n > 1) ans[0] *= n;

        while(ans[ans.length-1] === 1) ans.pop();
        ans.reverse();

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

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

let lines = [];

rl.on('line', (data) => {
    lines.push(data);
    if(lines.length > 0 && parseInt(lines[0]) === lines.length - 1) {
	rl.close();
	main();
    }
});

async function main() {
    let t = parseInt(lines[0]);
    for(let i = 1; i <= t; i++) {
	let n = parseInt(lines[i]);

	let factpow = {};
	for(let j = 2; j*j <= n; j++) {
	    if(n % j === 0) {
		factpow[j] = 0;
		while(n % j === 0) {
		    n /= j;
		    factpow[j]++;
		}
	    }
	}
	if(n != 1) {
	    factpow[n] = 1;
	}

	let lenmx = 0;
	for(const v in factpow) {
	    lenmx = Math.max(lenmx, factpow[v]);
	}

	let arr = [];
	for(let j = 0; j < lenmx; j++) {
	    arr.push(1);
	}

	for(const v in factpow) {
	    let power = factpow[v];
	    for(let j = lenmx - 1; j >= lenmx - power; j--) {
		arr[j] *= v;
	    }
	}

	console.log(lenmx);
	console.log(arr.join(' '));
    }
}

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

    while(t--) {
        var n = int(readline());
        primeFactors(n);
    }

}

// default parsers for JS.
function int(x) {
    return parseInt(x);
}

function float(x) {
    return parseFloat(x);
}

function primeFactors(n) {
    var fr = {};
    var mx = 0;

    while (n % 2 === 0) {
        if(fr[2] === undefined) fr[2] = 0;
        fr[2]++;

        n /= 2;
    }

    if(fr[2])
        mx = Math.max(fr[2], mx);

    for (var i = 3; i <= int(Math.sqrt(n)); i = i + 2) {
        var flag = n % i === 0;

        while (n % i === 0)
        {
            if(fr[i] === undefined) fr[i] = 0;
            fr[i]++;
            n /= i;
        }

        if(flag)
            mx = Math.max(mx, fr[i]);
    }

    if (n > 2)
        fr[n] = 1;

    if(fr[n])
        mx = Math.max(mx, fr[n]);

    var ans = new Array(mx).fill(1);
    Object.keys(fr).forEach(v => {
        var gt = mx - 1;
            var freq = fr[v];
            while(gt >= 0 && freq--) {
                ans[gt--] *= v;
            }
    })

    print(mx);
    var finalAns = "";
    ans.forEach(v => {
        finalAns += v + " ";

    });

    print(finalAns);
    /*for(auto val: ans) {
        printf("%lld ", val);
    }*/
}

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--) {
    let n = +readLine();
    let [count, pivot] = [0, null];
    let [maxCount, maxArr] = [-Infinity, []];

    for (let i = 2; i <= Math.sqrt(n); i++) {
      if (n % i === 0) {
        let [number, store] = [n, []];
        while (Number.isInteger(number / i) && (number / i) % i === 0) {
          store.push(i);
          number = number / i;
        }
        store.push(number);
        if (store.length > maxArr.length) {
          maxArr = store;
        }
      }
    }
    if (!maxArr.length) {
      console.log(1);
      console.log(n);
    } else {
      console.log(maxArr.length);
      console.log(maxArr.join(" "));
    }
  }
}

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

    while(t--) {
        var n = int(readline());
        primeFactors(n);
    }

}

// default parsers for JS.
function int(x) {
    return parseInt(x);
}

function float(x) {
    return parseFloat(x);
}

function primeFactors(n) {
    var fr = {};
    var mx = 0;

    while (n % 2 === 0) {
        if(fr[2] === undefined) fr[2] = 0;
        fr[2]++;

        n >>= 1;
    }

    if(fr[2])
        mx = Math.max(fr[2], mx);

    for (var i = 3; i <= Math.sqrt(n); i = i + 2) {
        var flag = n % i === 0;

        while (n % i === 0)
        {
            if(fr[i] === undefined) fr[i] = 0;
            fr[i]++;
            n /= i;
        }

        if(flag)
            mx = Math.max(mx, fr[i]);
    }

    if (n > 2)
        fr[n] = 1;

    if(fr[n])
        mx = Math.max(mx, fr[n]);

    var ans = new Array(mx).fill(1);
    Object.keys(fr).forEach(v => {
        var gt = mx - 1;
            var freq = fr[v];
            while(gt >= 0 && freq--) {
                ans[gt--] *= v;
            }
    })

    print(mx);
    var finalAns = "";
    ans.forEach(v => {
        finalAns += v + " ";

    });

    print(finalAns);
    /*for(auto val: ans) {
        printf("%lld ", val);
    }*/
}

main();


var testsCounter = parseInt(readline());

for (var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    var countPairs = 0;

    for (var j = 0; j < arrayLength; j++) {
        var currentResidue = array[j] - j;
        if (residueHash.has(currentResidue)) {
            var currentValue = residueHash.get(currentResidue);
            var counter = currentValue + 1;
            residueHash.set(currentResidue, counter);
            var newResidue = parseInt(residueHash.get(currentResidue));
        } else {
            residueHash.set(currentResidue, 0);
        }
    }

    var iterator = residueHash.values();

    for (var j = 0; j < residueHash.size; j++) {
        var counter = iterator.next().value;
        countPairs += (counter * (counter + 1)) / 2
    }

    print(countPairs);
}

const t=parseInt(readline());

for(var k=0;k<t;k++)
{
    var n=parseInt(readline());
    var map = new Map();
    var arr = readline().split(' ').forEach((v, i) => {
        var dif = parseInt(v) - i;
        if (map.has(dif))
            map.set(dif, map.get(dif) + 1);
        else
            map.set(dif, 1);
    });
    var counter = 0;
    map.forEach((v) => counter += v * (v - 1) / 2);
    print(counter);

}

var tests = parseInt(readline());
for (var test = 0; test < tests; test++) {
    var size = parseInt(readline());
    var map = new Map();
    var arr = readline().split(' ').forEach((v, i) => {
        var dif = parseInt(v) - i;
        if (map.has(dif))
            map.set(dif, map.get(dif) + 1);
        else
            map.set(dif, 1);
    });
    var counter = 0;
    map.forEach((v) => counter += v * (v - 1) / 2);
    print(counter);
}

var input = new Array(parseInt(readline()) * 2);
    for (var i = 0; i < input.length; i++) {
        input[i] = readline();
    }
    var output = calc(input);
    output.forEach(function (value) { print(value); });
    function calc(inputArray) {
        var result = new Array();
        for (var i = 0; i < inputArray.length; i += 2) {
            var caseLength = parseInt(inputArray[i]);
            var caseArray = inputArray[i + 1].split(" ");
            var resultArray = new Array(caseLength);
            for (var j = 0; j < caseLength; j++) {
                resultArray[j] = parseInt(caseArray[j]) - j;
            }
            resultArray.sort(function (a, b) { return a - b; });
            var currentTerm = resultArray[0];
            var seqLength = 1;
            var total = 0;
            for (var k = 1; k < caseLength; k++) {
                if (resultArray[k] === currentTerm) {
                    seqLength++;
                }
                else {
                    total += calcSeq(seqLength);
                    currentTerm = resultArray[k];
                    seqLength = 1;
                }
            }
            total += calcSeq(seqLength);
            result.push(total);
        }
        return result;
    }
    function calcSeq(seq) {
        var result = 0;
        for (var i = 1; i < seq; i++) {
            result += i;
        }
        return result;
    }

var T = parseInt(readline());
function nC2(n) { return n*(n-1)/2; }
while (T--) {
    var N = parseInt(readline());
    var M = N-1;
    var P = 2*N+1;
    var a = readline().split(" ");
    var count = new Array(P);
    for (var i = 0; i < P; ++i)
        count[i] = 0;
	for (var i = 0; i < N; ++i)
	    ++count[N+parseInt(a[i])-i];
	var ans = 0;
	for (var i = 0; i < P; ++i)
	    if (count[i] > 1)
	        ans += nC2(count[i]);
	print(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) => string.trim());

  main();
});

const readline = () => inputString[currentLine++];

// main logic

const main = () => {
  const numberOfTestCases = 1 * readline();
  // console.log("number of test cases", numberOfTestCases);
  Array.from({ length: numberOfTestCases }).forEach(() => {
    const arrayLength = 1 * readline();
    const arrayString = readline();
    const array = arrayString.split(" ");
    const arrayNum = array.map((x) => +x);

    // console.log(arrayNum);

    const map = new Map();
    let result = 0;
    for (let i = 0; i < arrayNum.length; i++) {
      const key = arrayNum[i] - i - 1;
      const current = map.get(key) || 0;
      result += current;
      map.set(key, current + 1);
    }
    console.log(result);
  });
};

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    for (let i = 0; i < n; i++) {
      arr[i] = arr[i] - (i + 1);
    }
    let obj = {},
      cnt = 1,
      flag = false;
    for (let i = 0; i < n; i++) {
      if (obj[arr[i]]) {
        flag = true;
        obj[arr[i]]++;
      } else obj[arr[i]] = 1;
    }
    if (flag) {
      let cnt = 0;
      for (let i of Object.keys(obj)) {
        let k = obj[i];
        if (k <= 1) continue;
        k--;
        cnt += (k * (k + 1)) / 2;
      }
      console.log(cnt);
    } else {
      console.log(0);
    }
  }
};
solve();

const solve = (arr) => {
    try {
        const set = {};

        for (let i = 0; i < arr.length; i += 1) {
            set[arr[i] - i] = (set[arr[i] - i] || 0) + 1;
        }

        let ans = 0;
        const keys = Object.values(set).filter((x) => x > 1);

        for (let i = 0; i < keys.length; i += 1) {
            ans += (keys[i] * (keys[i] - 1)) / 2;
        }

        return ans;
    } catch (ex) {
        console.log('ex:', ex);
    }
};

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
    const [n, ...lines] = input.trim().split('\n')
        .map(l => l.trim());

    for (let i=0; i<n; i++) {
        console.log(solve(lines[i*2+1].split(' ')))
    }
})

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

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

function main() {
	let t = +readLine();
	while (t--) {
		const len = +readLine();
		const arr = readLine().split(' ').map(Number);
		const obj = {};
		let ans = 0;
		for (let i = 0; i < len; i++) {
			arr[i] = arr[i] - i;
			const n = arr[i];
			obj[n] = (obj[n] || 0) + 1;
		}
		const values = Object.values(obj);
		for (let val of values) {
			if (val > 1) {
				ans += Math.floor((val * (val - 1)) / 2);
			}
		}
		console.log(ans);
	}
}

const solve = (arr) => {

	const set = {};
	for (let i=0; i<arr.length; i++) {
		set[arr[i] - i] = (set[arr[i] - i] || 0) + 1;
	}

	const keys = Object.values(set).filter(v => v > 1);

	let sum2 = 0;
	for (let i=0; i<keys.length; i++) {
		for (let j=1; j<keys[i]; j++) {
			sum2 += j;
		}
	}

	return sum2;
}

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const [n, ...lines] = input.trim().split('\n')
		.map(l => l.trim());

	for (let i=0; i<n; i++) {
		console.log(solve(lines[i*2+1].split(' ')))
	}
})

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

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

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

		let mp = new Map();
		let ans = 0;
		for (let i = 0; i < n; i++) {
			const key = a[i] - i;
			const vl = mp.has(key) ? mp.get(key) : 0;
			mp.set(key, vl + 1);
			ans += vl;
		}

		console.log(ans);
	}
}

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', line => {
    var t = Number(input[0]);
    var b = 1;
    for (var a = 0; a < t; a++) {
        var n = Number(input[b]);
        b++;
        var arr = input[b].split(" ").map((i) => {
            return Number(i);
        });
        b++;
        var map = new Map();
        var count = 0;
        for (var i = 0; i < arr.length; i++) {
            var diff = arr[i] - i;
            if (map.has(diff)) {
                count += map.get(diff);
                map.set(diff, map.get(diff) + 1);
            } else {
                map.set(diff, 1);
            }
        }
        console.log(count);
    }
})

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		var map = {};
		for(var j = 0; j < N; j++){
			var V = list[j] - j;
			if(map[V] == null){
				map[V] = 0;
			}
			map[V]++;
		}
		var key = Object.keys(map);
		var output = 0;
		for(var j = 0; j < key.length; j++){
			var add = map[key[j]];
			output += add * (add - 1) / 2;
		}
		myout(output);
	}
}

var t = readline();
t = Number(t);
while (t--) {
  var count = {},
    last = 0;
  var n = Number(readline());
  var array = readline().split(" ");
  for (var i = 1; i <= n; i++) {
    var test = "test" + ( array[i - 1] - i );
    count[test] = count[test] ? count[test] + 1 : 1;
  }
  for (var key in count) {
    last += count[key] > 1 ? (count[key] * (count[key] - 1)) / 2 : 0;
  }
  print(last);
}

var numberOfCases = Number(readline());
for (var i = 0; i < numberOfCases; ++i) {
    processCase();
}

function processCase() {
    var numberOfDigits = Number(readline());
    var array = readline().split(" ").map(x => Number(x));

    var distances = {};

    var pairsCount = 0;
    for (var i = 0; i < array.length; ++i) {
        var distance = array[i] - i;
        if (!distances[distance]) {
            distances[distance] = 0;
        }

        pairsCount += distances[distance];
        ++distances[distance];
    }

    print(pairsCount);
}

var testsCounter = parseInt(readline());

for (var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    var countPairs = 0;

    for (var j = 0; j < arrayLength; j++) {
        var currentResidue = array[j] - j;
        if (residueHash.has(currentResidue)) {
            var currentValue = residueHash.get(currentResidue);
            var counter = currentValue + 1;
            residueHash.set(currentResidue, counter);
            var newResidue = parseInt(residueHash.get(currentResidue));
        } else {
            residueHash.set(currentResidue, 0);
        }
    }

    for (var j = 0; j < residueHash.size; j++) {
        var counter = residueHash.values().next();
        countPairs += (counter * (counter + 1)) / 2
    }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for (var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    var countPairs = 0;

    for (var j = 0; j < arrayLength; j++) {
        var currentResidue = array[j] - j;
        if (residueHash.has(currentResidue)) {
            var currentValue = residueHash.get(currentResidue);
            var counter = currentValue + 1;
            residueHash.set(currentResidue, counter);
            var newResidue = parseInt(residueHash.get(currentResidue));
        } else {
            residueHash.set(currentResidue, 0);
        }
    }

    print(residueHash.values())

    // for (var [residue, counter] of residueHash) {
    //     countPairs += (counter * (counter + 1)) / 2
    // }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for (var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    var countPairs = 0;

    for (var j = 0; j < arrayLength; j++) {
        var currentResidue = array[j] - j;
        if (residueHash.has(currentResidue)) {
            var currentValue = residueHash.get(currentResidue);
            var counter = currentValue + 1;
            residueHash.set(currentResidue, counter);
            var newResidue = parseInt(residueHash.get(currentResidue));
        } else {
            residueHash.set(currentResidue, 0);
        }
    }

    // for (var [residue, counter] of residueHash) {
    //     countPairs += (counter * (counter + 1)) / 2
    // }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for(var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(parseInt(array[j]));
        if(currentValue) {
            residueHash.set(parseInt(array[j]), 0);
        } else {
            residueHash.set(parseInt(array[j]), parseInt(currentValue) + 1);
        }
    }

    var countPairs = 0;

    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(array[j]);
        countPairs =+ (parseInt(currentValue) * (parseInt(currentValue) + 1)) / 2
    }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for(var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(array[j]);
        if(currentValue) {
            residueHash.set(array[j], 0);
        } else {
            residueHash.set(array[j], parseInt(currentValue) + 1);
        }
    }

    var countPairs = 0;

    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(array[j]);
        countPairs =+ (parseInt(currentValue) * (parseInt(currentValue) + 1)) / 2
    }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for(var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(array[j]);
        if(currentValue) {
            residueHash.set(array[j], 0);
        } else {
            residueHash.set(array[j], currentValue + 1);
        }
    }

    var countPairs = 0;

    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(array[j]);
        countPairs =+ (currentValue * (currentValue + 1)) / 2
    }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for(var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    for(var j = 0; i < arrayLength; i++) {
        var currentValue = residueHash.get(array[j]);
        if(currentValue) {
            residueHash.set(array[j], 0);
        } else {
            residueHash.set(array[j], currentValue + 1);
        }
    }

    var countPairs = 0;

    for(var j = 0; i < arrayLength; i++) {
        var currentValue = residueHash.get(array[j]);
        countPairs =+ (currentValue * (currentValue + 1)) / 2
    }

    print(countPairs);
}

var t = readline()
t = Number(t)
while (t--) {
   var count = [], last = 0;
   var n = Number(readline())
   var array = readline().split(" ")
   for(var i = 1; i <= n; i++){
      if(array[i - 1] - i >= 0)
      count[array[i - 1] - i] = count[array[i - 1] - i]? count[array[i - 1] - i] + 1: 1
   }
   for(var i = 0; i < count.length; i++){
      if(count[i] > 1){
         last += ( count[i] * ( count[i] - 1 ) ) / 2
      }
   }
   print(last)
}

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

  main();
});

const readline = () => inputString[currentLine++];

// main logic

const main = () => {
  const numberOfTestCases = 1 * readline();
  // console.log("number of test cases", numberOfTestCases);
  Array.from({ length: numberOfTestCases }).forEach(() => {
    const arrayLength = 1 * readline();
    const arrayString = readline();
    const array = arrayString.split(" ");
    const arrayNum = array.map((x) => +x);

    console.log(arrayNum);

    const results = Array.from({ length: arrayLength }, () => 0);
    for (let i = 0; i < arrayNum.length; i++) {
      for (let j = i + 1; j < arrayNum.length; j++) {
        // console.log(
        //   "i",
        //   i,
        //   "j",
        //   j,
        //   "a_j",
        //   arrayNum[j],
        //   j - i + arrayNum[i] === arrayNum[j]
        // );
        if (j - i + arrayNum[i] === arrayNum[j]) {
          // console.log(".");
          results[j] += 1;
        }
      }
    }
    // console.log("results", results);
    console.log(results.reduce((i, j) => i + j, 0));
  });
};

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    for (let i = 0; i < n; i++) {
      arr[i] = Math.abs(arr[i] - i + 1);
    }
    let obj = {},
      cnt = 1,
      flag = false;
    for (let i = 0; i < n; i++) {
      if (obj[arr[i]]) {
        flag = true;
        obj[arr[i]]++;
      } else obj[arr[i]] = 1;
    }
    if (flag) {
      let cnt = 0;
      for (let i of Object.keys(obj)) {
        let k = obj[i];
        if (k <= 1) continue;
        k--;
        cnt += (k * (k + 1)) / 2;
      }
      console.log(cnt);
    } else {
      console.log(0);
    }
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    for (let i = 0; i < n; i++) {
      arr[i] = Math.abs(arr[i] - i + 1);
    }
    console.log(arr);
    let obj = {},
      cnt = 1,
      flag = false;
    for (let i = 0; i < n; i++) {
      if (obj[arr[i]]) {
        flag = true;
        obj[arr[i]]++;
      } else obj[arr[i]] = 1;
    }
    if (flag) {
      let cnt = 0;
      for (let i of Object.keys(obj)) {
        let k = obj[i];
        if (k <= 1) continue;
        k--;
        cnt += (k * (k + 1)) / 2;
      }
      console.log(cnt);
    } else {
      console.log(0);
    }
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    for (let i = 0; i < n; i++) {
      arr[i] = Math.abs(arr[i] - i + 1);
    }
    let obj = {},
      cnt = 1,
      flag = false;
    for (let i = 0; i < n; i++) {
      if (obj[arr[i]]) {
        flag = true;
        obj[arr[i]]++;
      } else obj[arr[i]] = 1;
    }
    if (flag) {
      for (let i of Object.keys(obj)) {
        let k = obj[i];
        if (k <= 1) continue;
        k--;
        console.log((k * (k + 1)) / 2);
      }
    } else {
      console.log(0);
    }
  }
};
solve();

const solve = (arr) => {
    try {
        const set = {};

        for (let i = 0; i < arr.length; i += 1) {
            set[arr[i] - i] = (set[arr[i] - i] || 0) + 1;
        }

        const keys = Object.values(set).filter((x) => x > 1).reduce((acc, curr) => acc + curr, 0);
        if (keys > 1) {
            return (keys * (keys - 1)) / 2;
        } else {
            return keys;
        }
    } catch (ex) {
        console.log('ex:', ex);
    }
};

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
    const [n, ...lines] = input.trim().split('\n')
        .map(l => l.trim());

    for (let i=0; i<n; i++) {
        console.log(solve(lines[i*2+1].split(' ')))
    }
})

const solve = (arr) => {
    try {
        const set = {};

        for (let i = 0; i < arr.length; i += 1) {
            set[arr[i] - i] = (set[arr[i] - i] || 0) + 1;
            arr[i] = arr[i] - i;
        }
        const keys = Object.values(set).filter((x) => x > 1).reduce((acc, curr) => acc + curr, 0);
        return (keys * (keys - 1)) / 2;
    } catch (ex) {
        console.log('ex:', ex);
    }
};

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
    const [n, ...lines] = input.trim().split('\n')
        .map(l => l.trim());

    for (let i=0; i<n; i++) {
        console.log(solve(lines[i*2+1].split(' ')))
    }
})

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

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

function main() {
	let t = +readLine();
	while (t--) {
		const len = +readLine();
		const arr = readLine().split(' ').map(Number);
		const obj = {};
		let max = -Infinity;
		for (let i = 0; i < len; i++) {
			arr[i] = arr[i] - i;
			const n = arr[i];
			obj[n] = (obj[n] || 0) + 1;
			max = Math.max(max, obj[n]);
		}
		const ans = Math.floor((max * (max - 1)) / 2);
		console.log(ans);
	}
}

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

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

function main() {
	let t = +readLine();
	while (t--) {
		const len = +readLine();
		const arr = readLine().split(' ').map(Number);
		const obj = {};
		let max = -Infinity;
		for (let i = 0; i < len; i++) {
			arr[i] = arr[i] - i;
			const n = arr[i];
			obj[n] = (obj[n] || 0) + 1;
			max = Math.max(max, obj[n]);
		}
		const ans = Math.floor(max * (max - 1)) / 2;
		console.log(ans);
	}
}


n=+readline();
while(n--){
   l=+readline();
   t=readline();
   if(l === 5){
      p = t.match(/(m|r|i|T|u)/g);
      newP=[...new Set(p)];
      print(p === null ? "NO" : newP.length === 5 ? "YES" : "NO" )
   }else{
      print("NO")
   }
}

(function main(){

    var t = readline();
    for(var i = 0; i<t;i++){
        var num = readline();
        var s = readline();
        if(num!="5"){
            print("NO");
            continue;
        }
        var T = 0;
        var idx = 0;
        var m = 0;
        var u = 0;
        var r = 0;
        for(var j = 0; j<num;j++){
          if(s[j] == 'T')
          T++;
          else if(s[j] == 'i')
          idx++;
          else if(s[j] == 'm')
          m++;
          else if(s[j] == 'u')
          u++;
          else if(s[j] == 'r')
          r++;
        }
        if(T&&idx&&m&&u&&r){
            print("YES");
        }else{
            print("NO");
        }

    }

})();

// import input from 'input'

var n = +(readline())

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

    if (compare("Timur", s)) {
        print("YES")
    } else {
        print("NO")
    }
}

function compare(s, d) {
    var k = 0;

    for (var i = 0; i < s.length; i++) {
        if (d.includes(s[i])) {
            k++;
        }
    }

    return k === s.length && k === d.length
}

var t = parseInt(readline());

while(t--){
    var nn = {T: 0, i: 0, m: 0, u: 0, r: 0};
    var n = parseInt(readline());
    var s = readline();
    var ret = false
    var i;
    for(i = 0; i < s.length; i++){
        if(nn[s[i]] === undefined){ print ("NO"); ret = true; break; }
        else nn[s[i]]++;
    }
    if(ret) continue;
    for(var k in nn){
        if(nn[k] !== 1) {print("NO"); ret = true; break;}
    }
    if(ret) continue;
    print("YES");

}

var n;

    var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        n = parseInt(readline());
        var s = readline();
        var m = {
            T: 0,
            i: 0,
            m: 0,
            u: 0,
            r: 0,
        };

        var ans = 'YES'
        for (var i = 0; i < s.length; i++) {
            if (m[s.charAt(i)] !== 0) {
                ans = 'NO';
                break;
            }
            m[s.charAt(i)]++;
        }

        var vals = Object.keys(m);
        var sum = 0;
        vals.forEach(x => sum += m[x]);
        if (sum != 5) {
            ans = 'NO';
        }
        print(ans);
    }

var t = +readline();

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

      var nums = [];
    var t1 = +readline();
    var t2 = readline();
    print(removePrefix(t2));

}

function removePrefix(num){

   return num.split('').sort().join('') === 'Timru' ? 'YES' : 'NO';

}

var t = parseInt(readline());

var origin = 'Timur'.split('').sort();

for (var test = 0; test < t; test++) {
    var n = parseInt(readline());
    var str = readline();

    if (n !== 5) {
        print('NO');
    } else {
        var arr = str.split('').sort();

        if (arr.join('') === origin.join('')) {
            print('YES');
        } else {
            print('NO');
        }
    }
}

var t = readline(),
    timurName = ["T" , "i" , "m" , "u" , "r"],
    sortedName = timurName.sort().toString();
    for(var i = 0 ; i < t ; i++){
    var n = readline(),
        s= readline().split(''),
        sortedInput = s.sort();
        if(sortedInput == sortedName ){
            print("YES");}
            else{
                print("NO");
            }
    }

/*
if length is 5
and includes T, i, m, u, r
yes, else no
*/
var n=readline();
for(var i=0;i<n;i++){
  var strlen = readline();
  var str = readline();
  if(strlen==5 && str.includes("T") && str.includes("i") && str.includes("m") && str.includes("u") && str.includes("r")){
    print("YES");
  } else {
    print("NO");
  }
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0],e=0;
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split('');
            var t = false, I = false, m = false, u = false, r = false;
                        if(e == 5){

            for(l = 0; l < e; l++){
                if(k[l] == 'T'){
                    t = true;
                }else if(k[l] == 'i'){
                    I = true;
                }else if(k[l] == 'm'){
                    m = true;
                }else if(k[l] == 'u'){
                    u = true;
                }else if(k[l] == 'r'){
                    r = true;
                }
            }
                        }
            if(t && I && m && u && r){
                console.log('YES');
            }else{
                console.log('NO');
            }

        }

    }
});

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var k = lines[i].split('');
            var timur = ['T', 'i', 'm', 'u', 'r'];
            if(n == 5){
                for(j = 0; j < n; j++){
                    for(l = 0; l < 5; l++){
                        if(k[j] == timur[l]){
                            timur.splice(l, 1);
                            break;
                        }
                    }
                }
                console.log(timur.length === 0 ? 'YES' : 'NO');
            }else{
                console.log('NO');
            }
        }
    }
});

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var k = lines[i].split('');
            var name = ['T', 'i', 'm', 'u', 'r'];
            var check = 0;
            if(n == 5){
                for(j = 0; j < n; j++){
                    for(l = 0; l < n; l++){
                        if(k[j] == name[l]){
                            check++;
                            name.splice(l, 1);
                        }
                    }
                }
                console.log(name.length === 0 ? 'YES' : 'NO');
            }else{
                console.log('NO');
            }
        }
    }
});

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

    for (let i = 0; i < n; i++) {
        const sz = parseInt(readline());
        let str = readline();

        if (sz != 5) {
            console.log("NO");
            continue;
        }

        console.log([...str].sort((a, b) => a.charCodeAt(0) - b.charCodeAt(0)).join('') == "Timru" ? "YES" : "NO");
    }
}

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

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

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

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

function main() {
    var t = parseInt(readline());
    const s = Array.from("Timur");
    s.sort();

    for (let i = 0; i < t; i++) {
        var n = parseInt(readline());
        var x = Array.from(readline());
        x.sort();
        var ok = true;
        if (n === 5)
        for (let i = 0;i < 5;++i) {
            // console.log(x[i],s[i]);
            if (x[i+1] != s[i]) {
                ok = false;
            }
        }
        if (n ===5 && ok) {
            console.log('YES');
        } else {
            console.log('NO');
        }

    }
}

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

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

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

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

function main() {
    var t = parseInt(readline());
    const s = Array.from("Timur");

    for (let i = 0; i < t; i++) {
        var n = parseInt(readline());
        var x = Array.from(readline());
        let cnt = 0;
        var hsh = new Array(5).fill(false);
        for (let i = 0; i < n;++i) {
            for (let j = 0;j < 5;++j) {
                if (hsh[j] === false && s[j] === x[i]) {
                    hsh[j] = true;
                    cnt++;
                }
            }
        }
        if (n === 5 && cnt === 5) {
            console.log('YES');
        } else {
            console.log('NO');
        }

    }
}

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

//   .........................................................   //

const main=()=>{
    const testCase =parseInt(readLine());

    for (let index = 1; index <= testCase; index++) {
        const length =parseInt(readLine());
        const string = readLine();
        console.log(spellCheck(length, string));

    }
}

const spellCheck = (length, string) => {
    const sort = str => str.split('').sort((a, b) => a.localeCompare(b)).join('');
    const name = 'Timur';
    if (sort(name) === sort(string))
        return 'YES';

    else
        return 'NO'
}

let readline = require("readline");
const { start } = require("repl");

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

let input = [];
rl.on("line", function (line) {
  input.push(line);

  if (input.length === +input[0] * 2 + 1) {
    // call your function here
    solve(input);
    rl.close();
  }
});

let solve = (input) => {
  let name = ["T", "i", "m", "u", "r"];

  for (let i = 1; i < input.length; i += 2) {
    if (+input[i] !== 5) {
      console.log("NO");
      continue;
    } else {
      let count = 0;
      let test = input[i + 1];

      for (let j = 0; j < name.length; j++) {
        if (test.includes(name[j])) count++;
        else {
          console.log("NO");
          break;
        }
      }

      if (count === 5) console.log("YES");
    }
  }
};

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var ok = "Timur";
	while(hasNext()){
		var N = nextInt();
		var s = next();
		var map = {};
		var isOK = true;
		for(var i = 0; i < N; i++){
			if(ok.indexOf(s[i]) == -1){
				isOK = false;
				break;
			}else if(map[s[i]]){
				isOK = false;
				break;
			}
			map[s[i]] = true;
		}
		for(var i = 0; i < ok.length; i++){
			if(map[ok[i]] == null){
				isOK = false;
				break;
			}
		}
		if(isOK){
			myout("Yes");
		}else{
			myout("No");
		}
	}
}

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

let c = 0;
const original = ["T", "i", "m", "r", "u"];

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

  if (c % 2 !== 0) {
    c++;
    return;
  }

  const chars = [...d].sort();
  let ans = "YES";

  for (let i = 0; i < original.length; i++) {
    if (original[i] !== chars[i]) {
      ans = "NO";
      break;
    }
  }

  if (chars.length !== original.length) {
    ans = "NO";
  }

  console.log(ans);
  c++;
});

rl.on("close", () => {});

// Common Template Starts //
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = ""
let currentLine = 0

process.stdin.on("data", inputStdin => inputString += inputStdin)

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

const readline = () => inputString[currentLine++]
// Common Template Ends //

// Driver Function Starts //
const main = () => {
    console.clear()
    let t = parseInt(readline())
    while (t--) {
        let n = parseInt(readline())
        let s = readline()
        console.log( solve(n,s) )
    }
}
// Driver Function Ends //

// MAIN LOGIC
const solve = (n, s) => {
    if( n != 5 ) return 'NO'

    let flag = false

    if( s.includes("T") ) {
	    if( s.includes("i") ) {
		    if( s.includes("m") ) {
			    if( s.includes("u") ) {
				    if( s.includes("r") ) {
				    	return 'YES'
				    }
			    }
		    }
	    }
    }

    return 'NO'
}

// 12339
// 0
// 15
// 54306
// 999999995
// 185
// 999999998

const isOdd         = (num) => num & 1
const isEven        = (num) => !(num & 1)
const minOfArray    = (arr) => Math.min.apply(null, arr)
const maxOfArray    = (arr) => Math.max.apply(null, arr)
const uniqueArray   = (arr) => [...new Set(arr)]
const sortArray     = (arr) => arr.sort((a, b) => a - b)
const sumOfArray    = (arr) => arr.reduce((partialSum, a) => partialSum + a, 0)

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

let inputString = "";

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

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

  main();
});

function main() {
  const testCases = inputString[0];

  for (let i = 1; i <= testCases * 2; i += 2) {
    const length = Number(inputString[i]);
    const str = inputString[i + 1].split("");
    if (length !== 5) console.log("NO");
    else {
      const name = new Set("Timur".split(""));
      str.forEach(e => name.delete(e));
      if(name.size === 0) console.log("YES");
      else console.log("NO");
    }
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

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

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

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

        let t = ('Timur').split('');
        t.sort();
        s.sort();
        output(t.join('') === s.join('') ? 'YES' : 'NO');
    }
}

"use strict";

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

let inputString = "";
let currentLine = 0;

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

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

  main();
});

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

// Main Function, write code here

function main() {
  let T = readline();
  for (let i = 0; i < T; i++) {
    const n = readline();
    const str = readline();
    let timur = "Timur".split("").sort().join("");
    const strSorted = str.split("").sort().join("");
    console.log(timur === strSorted ? 'Yes' : 'No');
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const numberOfTest = Number.parseInt(readline());
    for(let i=0; i<numberOfTest; i++){
        const strLength = Number.parseInt(readline());
        const str = readline();
        Solution(strLength, str);
    }
}

function Solution(n, s){
    const nameSet = new Set(['T', 'i', 'm', 'u', 'r']);
    const length = nameSet.size;
    let result = "NO";
    if(n == length){
        for(let j=0; j<length; j++){
            const value = s.charAt(j);
            if(nameSet.has(value)){
                nameSet.delete(value);
            }
        }
        if(nameSet.size == 0){
            result = "YES"
        }
    }
    console.log(result);
}

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

let lines = [];
rl.on('line', (line) => {
    lines.push(line);
}).on('close', () => {
    // input in lines
    solve();
});

let line = 0;
const readline = () => lines[line++];

solve = () => {
    const t = parseInt(readline());
    for (let i = 0; i < t; i++) {
        var n = parseInt(readline());
        var s = readline();
        if (n === 5 && s.includes('T') && s.includes('i') && s.includes('m') && s.includes('u') && s.includes('r')) {
            console.log("YES");

        } else {
            console.log("NO");
        }
    }
}

const readline = require('readline')

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

function solve(n, str) {
    // str = 'Timur'
    return str.split('')
        .sort((a, b) => a < b ? -1 : (a > b ? 1 : 0))
        .join('') === 'Timru' ? 'YES' : 'NO'
}

let fs = require("fs");
let sc = {
    _buf: new Buffer.alloc(1 << 14),
    _bufPos: 0,
    _bufLen: 0,
    _ensure: function ()
    {
        if (this._bufPos === this._bufLen)
        {
            this._bufPos = 0;
            this._bufLen = fs.readSync(0, this._buf, 0, this._buf.length, null);
        }
    },
    _isws: function (ch)
    {
        return ch === 32 || ch === 9 || ch === 10 || ch === 13;
    },
    _islf: function (ch)
    {
        return ch === 10 || ch === 13;
    },
    _peekChar: function ()
    {
        this._ensure();
        return this._bufPos === this._bufLen ? 0 : this._buf[this._bufPos];
    },
    _skipWs: function ()
    {
        while (this._isws(this._peekChar()))
            this._bufPos++;
    },
    _readUntil: function (stop)
    {
        this._ensure();
        if (this._bufPos === this._bufLen)
            throw new Error("eof");
        let start = this._bufPos;
        let before = null;
        for (; ;)
        {
            if (this._bufPos === this._bufLen)
            {
                let len = this._bufPos - start, preLen = (before ? before.length : 0);
                let nbuf = new Buffer(len + preLen);
                if (before)
                    before.copy(nbuf);
                before = nbuf;
                this._buf.copy(before, preLen, start);
                this._ensure();
                start = this._bufPos;
            }
            if (this._bufPos === this._bufLen || stop(this._buf[this._bufPos])) break;
            this._bufPos++;
        }
        if (!before)
            return this._buf.toString("utf8", start, this._bufPos);
        let after = this._buf.slice(start, this._bufPos);
        let res = new Buffer(before.length + after.length);
        before.copy(res);
        after.copy(res, before.length);
        return res.toString();
    },

    nextToken: function ()
    {
        this._skipWs();
        return this._readUntil(this._isws);
    },
    L: function ()
    {
        let line = this._readUntil(this._islf);
        if (this._peekChar() === 13) this._bufPos++;
        if (this._peekChar() === 10) this._bufPos++;
        return line;
    },
    N: function ()
    {
        return +this.nextToken();
    },
    S: function ()
    {
        return this.nextToken();
    }
};

// DO NOT CHANGE TEMPLATE BEFORE

const Def = Number(1e9);

const LowerBound = (arr, val) =>
{
    let ng = -1;
    let ok = arr.length;
    while (ok - ng > 1)
    {
        let med = (ok + ng) / 2 | 0;
        if (arr[med] >= val)
        {
            ok = med;
        }
        else
        {
            ng = med;
        }
    }

    return ok;
}

const ReverseLowerBound = (arr, val) =>
{
    let ng = 0;
    let ok = arr.length;
    while (ok - ng > 1)
    {
        let med = (ok + ng) / 2 | 0;
        if (arr[med] <= val)
        {
            ng = med;
        }
        else
        {
            ok = med;
        }
    }
    // Находит наибольший элемент который меньше или равен val
    return ng;
}

const ReverseUpperBound = (arr, val) =>
{
    let ng = 0;
    let ok = arr.length;
    while (ok - ng > 1)
    {
        let med = (ok + ng) / 2 | 0;
        if (arr[med] < val)
        {
            ng = med;
        }
        else
        {
            ok = med;
        }
    }
    // Находит наибольший элемент который меньше val
    return ng;
}

const UpperBound = (arr, val) =>
{
    let ok = arr.length;
    let ng = -1;
    while (ok - ng > 1)
    {
        let med = (ok + ng) / 2 | 0;
        if (arr[med] > val)
        {
            ok = med;
        }
        else
        {
            ng = med;
        }
    }

    return ok;
}

const Solve = () =>
{
    let n = sc.N();
    let s = sc.S();

    if (n !== 5)
    {
        console.log("NO");
        return;
    }

    let arr = ['T', 'i', 'm', 'r', 'u'];
    let r = [...s];
    r.sort();

    let e = true;
    for (let i = 0; i < 5; ++i)
    {
        if (arr[i] !== r[i])
        {
            console.log("NO");
            return;
        }
    }

    console.log("YES");

}

const main = () =>
{
    let cases = +sc.L();
    while (cases-- > 0) Solve();

    // Solve();
}
main();

n=+readline();
while(n--){
   l=+readline();
   t=readline();
   if(l === 5){
      p = t.match(/(Timur|miurT|Trumi|mriTu)/g);
      print(p !== null ? "Yes" : "No")
   }else{
      print("NO")
   }
}

n=+readline();

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

   if(l == 5){
      p=t.match(/(Timur|miurT|Trumi|mriTu)/g) == null ? "" : t.match(/(Timur|miurT|Trumi|mriTu)/g) ;
      if( p.length == 1){
         print( t == "Timur" || t == "miurT" || t== "Trumi" || t== "mriTu" ? "YES" : "NO")
      }else{
      print("NO")
      }
   }else{
      print("NO")
   }
}

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

   l=readline();
   t=readline();

   p=t.match(/(Timur|miurT|Trumi|mriTu)/g) || "" ;

   if(l == 5){

      if( p.length == 1){

      print( t == "Timur" || t == "miurT" || t== "Trumi" || t== "mriTu" ? "YES" : "NO")

      }else{

      print("NO")

      }

   }else{

      print("NO")
   }

}

n=readline();
for(i=0;i<n;i++){
   l=readline();
   t=readline();
   if(+l === 5){
      print( t == "Timur" || t == "miurT" || t== "Trumi" || t== "mriTu" ? "YES" : "NO")
   }else{
      print("NO")
   }
}

(function main(){

    var t = readline();
    for(var i = 0; i<t;i++){
        var num = readline();
        var s = readline();
        if(num!=5){
            print("No");
        }
        var T = 0;
        var idx = 0;
        var m = 0;
        var u = 0;
        var r = 0;
        for(var j = 0; j<num;j++){
          if(s[j] == 'T')
          T++;
          else if(s[j] == 'i')
          idx++;
          else if(s[j] == 'm')
          m++;
          else if(s[j] == 'u')
          u++;
          else if(s[j] == 'r')
          r++;
        }
        if(T&&idx&&m&&u&&r){
            print("YES");
        }else{
            print("NO");
        }

    }

})();

(function main(){

    var t = readline();
    for(var i = 0; i<t;i++){
        var num = readline();
        var s = readline();
        if(num!=5){
            print("No");
        }
        var T = 0;
        var idx = 0;
        var m = 0;
        var u = 0;
        var r = 0;
        for(var j = 0; j<num;j++){
          if(s[j] == 'T')
          T++;
          else if(s[j] == 'i')
          idx++;
          else if(s[j] == 'm')
          m++;
          else if(s[j] == 'u')
          u++;
          else if(s[j] == 'r')
          r++;
        }
        if(T&&idx&&m&&u&&r){
            print("No");
        }else{
            print("No");
        }

    }

})();

// import input from 'input'

var n = +(readline())
var t = 'Timur'

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

    if (compare(t, s)) {
        print("YES")
    } else {
        print("NO")
    }
}

function compare(s, d) {
    var k = 0;

    for (var i = 0; i < s.length; i++) {
        if (d.includes(s[i])) {
            k++;
        }
    }

    return k === s.length
}

var t = parseInt(readline());

while(--t){
    var nn = {T: 0, i: 0, m: 0, u: 0, r: 0};
    var n = parseInt(readline());
    var s = readline();
    var ret = false
    var i;
    for(i = 0; i < s.length; i++){
        if(nn[s[i]] === undefined){ print ("NO"); ret = true; break; }
        else nn[s[i]]++;
    }
    if(ret) continue;
    for(var k in nn){
        if(nn[k] !== 1) {print("NO"); ret = true; break;}
    }
    if(ret) continue;
    print("YES");

}

var t = +readline();

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

      var nums = [];
    var t1 = +readline();
    var t2 = readline();
    print(removePrefix(t2));

}

function removePrefix(num){

 if (num.length != 5) return 'NO';

    var str = 'Timur';
 var count = 0;
  for(var each of num){
          if (str.indexOf(each) == -1)return 'NO';
          count++;

  }
  if (count == 5){
          return 'YES'
          }else {
                  return 'NO'
}

}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0],e=0
    for(j = 1; j <= n *2; j++){
        if(j % 2 == 1){
            e = lines[j], t = false, I = false, m = false, u = false, r = false
        }else{
            if(e == 5){
                for(l = 0; l < e; l++){
                    var k = lines[j].split('')
                    if(k[l] == 'T' && t === false){
                        t = true
                    }else if(k[l] == 'i' &&I === false){
                        i = true
                    }else if(k[l] == 'm' && m === false){
                        m = true
                    }else if(k[l] == 'u' && u === false){
                        u = true
                    }else if(k[l] == 'r' && r === false){
                        r = true
                    }
            }
            }
            if(t === true && I === true && m === true && u === true && r === true ){
                console.log('YES')
            }else{
                console.log('NO')
            }
        }

    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0],e=0
    for(j = 1; j <= n; j++){
        if(j % 2 == 1){
            e = lines[j]
        }else{
            if(e == 5){
                for(l = 0; l < e; l++){
                    var k = lines[j].split(''), t = false, I = false, m = false, u = false, r = false
                    if(k[l] == 'T' && t === false){
                        t = true
                    }else if(k[l] == 'i' &&I === false){
                        i = true
                    }else if(k[l] == 'm' && m === false){
                        m = true
                    }else if(k[l] == 'u' && u === false){
                        u = true
                    }else if(k[l] == 'r' && r === false){
                        r = true
                    }
            }
            }
            if(t === true && I === true && m === true && u === true && r === true ){
                console.log('YES')
            }else{
                console.log('NO')
            }
        }

    }
});

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

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

        if (sz != 5) {
            console.log("NO");
            continue;
        }

        let str = readline();
        console.log([...str].sort((a, b) => a.charCodeAt(0) - b.charCodeAt(0)).join('') == "Timru" ? "YES" : "NO");
    }
}

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

//   .........................................................   //

const main=()=>{
    const testCase =parseInt(readLine());

    for (let index = 1; index <= testCase; index++) {
        const length =parseInt(readLine());
        const string = readLine();
        console.log(spellCheck(length, string));

    }
}

const spellCheck = (length, string) => {
    const name = 'Tumir';
    if (name.length != string.length)
        return 'NO';
    let count = 0;
    for (let index = 0; index < name.length; index++) {
        for (let j = 0; j < string.length; j++) {
            if (name[index] === string[j]) {
                count++;
            }

        }

    }
    if (count === name.length) {
        return 'YES'
    }
    else
        return 'NO'
}

let readline = require("readline");
const { start } = require("repl");

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

let input = [];
rl.on("line", function (line) {
  input.push(line);

  if (input.length === +input[0] * 2 + 1) {
    // call your function here
    solve(input);
    rl.close();
  }
});

let solve = (input) => {
  let name = {
    T: true,
    i: true,
    m: true,
    u: true,
    r: true,
  };

  for (let i = 1; i < input.length; i += 2) {
    if (+input[i] !== 5) {
      console.log("NO");
      continue;
    } else {
      let count = 0;
      for (let j = 0; j < input[i + 1].length; j++) {
        if (name[input[i + 1][j]]) {
          count++;
        }
      }
      if (count === 5) {
        console.log("YES");
      } else {
        console.log("NO");
      }
    }
  }
};

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var list = ["Timur", "miurT", "Trumi", "mriTu"];
	while(hasNext()){
		var N = nextInt();
		var s = next();
		if(list.indexOf(s) > -1){
			myout("Yes");
		}else{
			myout("No");
		}
	}
}


function solveAll(inputs) {
    inputs.forEach(input => {
        let lastLet = input;
        let valid = true;
        while (valid) {
            let pref = lastLet[0]
            valid = lastLet.slice(1, lastLet.length).includes(pref)
            if (valid) lastLet = lastLet.slice(1, lastLet.length);
        }
        console.log(lastLet)
    });
}

const rl = require('readline').createInterface(process.stdin, process.stdout);
let testCase = 0; const inputs = []
rl.on('line', (data) => {
    if (testCase === 0) testCase = parseInt(data)
    else {
        inputs.push(data)
        if (inputs.length === testCase) { solveAll(inputs); rl.close() };
    }
})

var t = readline();

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

  var f = 0;
  var s = 0;
  for (var j = 0; j < a.length; j++) {
    for (var k = j + 1; k < a.length; k++) {
      if (a[j] === a[k]) {
        s = j + 1;
        break;
      }

      if(k === a.length - 1  &&  a[j] !== a[k]) {
        f = 1;
        break;
      }
    }

    if (f === 1) {
      break;
    }
  }
  print(a.substring(s));
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

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

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

    for (let test = 0; test < N; test++) {
        let s = readline();
        let arr = s.split('');

        if (s.length === 1) {
            output(s);
            continue;
        }

        let freq = {};
        for (let i = 0; i < arr.length; i++) {
            if (freq[arr[i]]) {
                freq[arr[i]]++;
            } else {
                freq[arr[i]] = 1;
            }
        }

        let count = Object.keys(freq).length;

        let freq2 = {};
        for (let i = s.length - 1; i >= 0; i--) {
            if (!freq2[s[i]]) {
                freq2[s[i]] = true;
            }

            if (Object.keys(freq2).length === count) {
                output(s.slice(i));
                break;
            }
        }
    }
}

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(s) {
  const map = new Map();
  for (let char of s) {
    var _map$get;
    map.set(char, ((_map$get = map.get(char)) !== null && _map$get !== void 0 ? _map$get : 0) + 1);
  }
  for (let [i, char] of [...s].entries()) {
    if (map.get(char) > 1) {
      map.set(char, map.get(char) - 1);
    } else {
      return s.slice(i);
    }
  }
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const s = await read();
    res.push(solve(s));
  }
  console.log(res.join('\n'));
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

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

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

const EPS = 1e-6;

let calc = (s)=>{
  let map = new Map();
  for (let i=0; i<s.length; i++){
    map.set(s[i], (map.get(s[i])||0) + 1);
  }
  for (let i=0; i<s.length; i++){
    let cnt = map.get(s[i]);
    if (cnt==1)
      return s.slice(i);
    map.set(s[i], cnt - 1);
  }
};
// codecxcode -> cxcode
// xcode

function main() {
    let T = +readline();
    while (T--){
      let s = readline();
      print(calc(s));
    }
}

function solve() {
   const str = read();
   const charSet = new Set();
   for (let i = 0; i < str.length; i++) {
      charSet.add(str[i]);
   }
   const currentSet = new Set();
   for (let i = str.length - 1; i >= 0; i--) {
      currentSet.add(str[i]);
      if (currentSet.size === charSet.size) {
         write(str.substring(i));
         return;
      }
   }
}

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

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1n;
   while(curN) {
      if (curN & 1n) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1n;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

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

function readArray(f) {
   return read().split(' ').map(f);
}

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;

   var needWriteFile = false;

   var writeResult = '';
   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();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var S = nextCharArray();
		var map = getCountMap(S);
		var output = [];
		var N = S.length;
		var ok = false;
		for(var i = 0; i < N; i++){
			if(map[S[i]] > 1 && !ok){
				map[S[i]]--;
			}else{
				output.push(S[i]);
				ok = true;
			}
		}
		myout(myconv(output, 0));
	}
}

var t = readline();

for (var i = 0; i < t; i++) {
  var n = readline();
  var arr = Array.from(n);
  var res = arr.reverse().filter((el, i) => arr.indexOf(el) === i);
  print(res.reverse().join(''));
}

var t = readline();

for (var i = 0; i < t; i++) {
  var a = readline().split(' ').map(Number);
  var n = a[0];
  var B = a[1], x = a[2], y = a[3];
  var sum = 0;
  var ans = 0;

  while(n > 0) {
    sum += sum + x <= B ? x : -y;
    ans += sum;
    n--;
  }
  print(ans);
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

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

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

    for (let test = 0; test < N; test++) {
        let s = readline();
        let freq = {};
        let i = s.length - 1;
        for (; i >= 0; i--) {
            if (!freq[s[i]]) {
                freq[s[i]] = 1;
            } else break;
        }
        output(s.slice(i));
    }
}