We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.

The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains n space-separated integers xi (1 ≤ xi ≤ 1012). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64d specifier.

Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.

NoteThe given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".

var i, j, l,
	sqrt = Math.sqrt,
	N = 1e6 + 5,
	p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 4; j < N; j += 2)
	p[j] = 1;

for (i = 3, l = Math.sqrt(N); i < l; i += 2)
	if (!p[i])
		for (var j = i * i; j < N; j += i)
			p[j] = 1;

readline();
print(readline().replace(/\s*\d+/g, function(v) {
	v = sqrt(+v);
	return v % 1 === 0 && p[v] === 0 ? 'YES\n' : 'NO\n';
}));

var i, j, l,
	N = 1e6 + 5,
	p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 2; j * 2 < N; j++)
	p[j * 2] = 1;
for (i = 3, l = Math.sqrt(N); i < l; i += 2)
	if (!p[i])
		for (var j = i * i; j < N; j += i)
			p[j] = 1;

readline();
print(readline().split(' ').map(function(v) {
	v = Math.sqrt(v);
	return v % 1 === 0 && p[v] === 0 ? 'YES' : 'NO';
}).join('\n'));

var i, j, l,
	N = 1e6 + 5,
	p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 2; j * 2 < N; j++)
	p[j * 2] = 1;
for (i = 3, l = Math.sqrt(N); i < l; i += 2)
	if (!p[i])
		for (var j = i * i; j < N; j += i)
			p[j] = 1;

readline();
print(readline().split(' ').map(Math.sqrt).map(function(v) {
	return v % 1 === 0 && p[v] === 0 ? 'YES' : 'NO';
}).join('\n'));

var i, j, l,
  sqrt = Math.sqrt,
  N = 1e6 + 5,
  p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 4; j < N; j += 2)
  p[j] = 1;

for (i = 3, l = Math.sqrt(N); i < l; i += 2)
  if (!p[i])
    for (var j = i * i; j < N; j += i)
      p[j] = 1;

var n = readline();
var a = readline().split(' ');
var ans = [];
for (var i = 0; i < n; i++) {
  var v = sqrt(a[i]);
  ans.push(v % 1 === 0 && p[v] === 0 ? 'YES' : 'NO');
}
print(ans.join('\n'));

var i, j, l,
  sqrt = Math.sqrt,
  N = 1e6 + 5,
  p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 4; j < N; j += 2)
  p[j] = 1;

for (i = 3, l = Math.sqrt(N); i < l; i += 2)
  if (!p[i])
    for (var j = i * i; j < N; j += i)
      p[j] = 1;

var n=readline();
var a=readline().split(' ')
var ans='';
for(var i=0; i<n; i++){
  var v=sqrt(a[i]);
  ans += v % 1 === 0 && p[v] === 0 ? 'YES\n' : 'NO\n';
}
print(ans)

var N = 1e6 + 5;
var p = new Int8Array( N );

p[0] = p[1] = 1;

for( var j = 2; j*2 < N; j++ )
	p[ j*2 ] = 1;

for( var i = 3; i < N; i+=2 )
	if( !p[i] )
		for( var j = i*i; j < N; j+=i )
			p[ j ] = 1;

readline();
var ret = readline()
			.split(' ')
			.map(Math.sqrt)
			.map(function(v){
				return v%1===0&&p[v]===0 ? 'YES' : 'NO';
			});

print(ret.join('\n'));

var N = 1e6 + 5;
var p = new Int8Array( N );

p[0] = p[1] = 1;

for( var j = 2; j*2 < N; j++ )
	p[ j*2 ] = 1;

for( var i = 3; i < N; i+=2 )
	if( !p[i] )
		for( var j = 2; j*i < N; j++ )
			p[ j*i ] = 1;

readline();
var ret = readline()
			.split(' ')
			.map(Math.sqrt)
			.map(function(v){
				return v%1===0&&p[v]===0 ? 'YES' : 'NO';
			});

print(ret.join('\n'));

var N = 1e6 + 5;
var p = new Int8Array( N );

p[0] = p[1] = 1;

for( var j = 2; j*2 < N; j++ )
	p[ j*2 ] = 1;

for( var i = 3; i < N; i++ )
	if( !p[i] )
		for( var j = 2; j*i < N; j++ )
			p[ j*i ] = 1;

readline();
var ret = readline()
			.split(' ')
			.map(Math.sqrt)
			.map(function(v){
				return p[v]===0 ? 'YES' : 'NO';
			});

print(ret.join('\n'));

var N = 1e6 + 5;
var p = new Int8Array( N );

p[0] = p[1] = 1;

for( var j = 2; j*2 < N; j++ )
	p[ j*2 ] = 1;

for( var i = 3, l=Math.sqrt(N); i < l; i+=2 )
	if( !p[i] )
		for( var j = i*i; j < N; j+=i )
			p[ j ] = 1;

readline();
var ret = readline()
			.split(' ')
			.map(Math.sqrt)
			.map(function(v){
				return v%1===0&&p[v]===0 ? 'YES' : 'NO';
			});

print(ret.join('\n'));

var i, j, l,
	N = 1e6 + 5,
	p = new Int8Array(N),
	q = {};

p[0] = p[1] = 1;
q[4] = true;

for (i = 3; i < N; i += 2)
	if (!p[i]) {
		q[i * i] = true;
		for (var j = i * i; j < N; j += i)
			p[j] = 1;
	}

readline();
print(readline().split(' ').map(function(v) {
	return q[v] ? 'YES' : 'NO';
}).join('\n'));

var i, j, l,
	sqrt = Math.sqrt,
	N = 1e6 + 5,
	p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 4; j < N; j += 2)
	p[j] = 1;

for (i = 3, l = Math.sqrt(N); i < l; i += 2)
	if (!p[i])
		for (var j = i * i; j < N; j += i)
			p[j] = 1;

readline();
print(readline().split(' ').map(function(v) {
	v = sqrt(+v);
	return v % 1 === 0 && p[v] === 0 ? 'YES' : 'NO';
}).join('\n'));

var N = 1e6 + 5;
var p = new Int8Array( N );

p[0] = p[1] = 1;

for( var j = 2; j*2 < N; j++ )
	p[ j*2 ] = 1;

for( var i = 3; i < N; i+=2 )
	if( !p[i] )
		for( var j = 2; j*i < N; j++ )
			p[ j*i ] = 1;

readline();
var ret = readline()
			.split(' ')
			.map(Math.sqrt)
			.map(function(v){
				return p[v]===0 ? 'YES' : 'NO';
			});

print(ret.join('\n'));

'use strict'
let r;
function getReshetoNum(maxNum) {
  r = new Array(maxNum + 1);
  r[0] = 0;
  r[1] = 0;
  for (let i = 2; i <= Math.sqrt(maxNum + 1); i++) {
    if (r[i] === undefined) {
      for (let j = i + i; j <= maxNum; j += i) {
        r[j] = 1;
      }
    }
  }
}

getReshetoNum(1000000);

function isSimple(num) {

  if (r[num] === undefined) {
    return true;
  }
  return false;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = parseInt(Math.sqrt(num));
  if (num === 1) {
    write('NO\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

var n = parseInt(readline(), 10);
var inp = readline().split(' ');

for(var i=0; i<inp.length; i++) {
    inp[i] = parseInt(inp[i], 10);
}

for(var i=0; i<inp.length; i++) {
    var valid = true;
    var sqrt = Math.sqrt(inp[i]);
    if(Math.ceil(sqrt) === sqrt && inp[i] !== 1) {
        for(var j = 2; j*j<=sqrt; j++) {
            if(sqrt % j === 0) {
                valid = false;
                break;
            }
        }
    } else {
        valid = false;
    }

    print(valid ? "YES" : "NO");
}

var prime = new Array(Math.pow(10, 6));
prime[0] = true;
prime[1] = true;

var tPrimes = new Set();

function getAllPrimes(){
    for(var i = 2; i <= Math.pow(10, 6); i++){
        if(prime[i] === undefined){
            // number is unmarked so we know it's prime
            prime[i] = true;
            var j = i * i;
            while(j <= Math.pow(10, 6)){
                prime[j] = false;
                j = j + i;
            }
        }
    }
}

function getAllTPrimes(){
    for(var i = 2; i < prime.length; i++){
        if(prime[i] === true) {
            tPrimes.add(i * i);
        }
    }
}

getAllPrimes();
getAllTPrimes();

function isTPrime(number){
    if(tPrimes.has(number)){
        print("YES");
    }
    else {
        print("NO");
    }
}

const line1 = readline();
const line2 = readline().split(" ").map(x => parseInt(x));
for(var i = 0; i < line2.length; i++){
    isTPrime(line2[i]);
}

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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

function primesNums(map) {
  const N = 1e12;
  const sN = Math.trunc(Math.sqrt(N)) + 10;

  const nums = new Array(sN).fill(true);
  nums[0] = false;
  nums[1] = false;

  let i = 2;
  while (i <= sN) {
    if (nums[i]) {
      map.add(i);
      let j = i + i;
      nums[j] = false;
      while (j <= sN) {
        nums[j] = false;
        j += i;
      }
      nums[j] = false;
    }
    i += 1;
  }
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  const nums = splitAndParseInt(input[1]);

  const primes = new Set();
  primesNums(primes);

  nums.forEach((x) => {
    const sqrt = Math.sqrt(x);
    if (primes.has(sqrt)) console.log(`YES`);
    else console.log("NO");
  });
});

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

const input = [];
readLine.on('line', line => input.push(line));

function findAllSimple(map) {
  const N = 1000000000000;

  const nums = Array(1000001).fill(true);
  let i = 2; nums[0] = false; nums[1] = false;
  while (i**2 <= 1000000000001) {
    if (nums[i]) {
      map.add(i);
      let j = i ** 2;
      while (j <=  1000001) {
        nums[j] = false;
        j += i;
      }
    }
    i += 1;
  }
}

readLine.on('close', () => {
  const [n] = input[0].split(' ').map(x => parseInt(x));
  const primeNumbers = new Set();

  findAllSimple(primeNumbers);

  input[1].split(' ').forEach(x => {
    if (primeNumbers.has(Math.sqrt(x))) console.log(`YES`);
    else console.log('NO');
  });
});

var i, j, l,
	N = 1e6 + 5,
	p = new Int8Array(N),
	q = {};

p[0] = p[1] = 1;
for (i = 2, l = Math.sqrt(N); i < l; i++)
	if (!p[i]){
		q[i*i]=true;
		for (var j = i * i; j < N; j += i)
			p[j] = 1;
	}

readline();
print(readline().split(' ').map(function(v) {
	return q[v] ? 'YES' : 'NO';
}).join('\n'));

var i, j, l,
	sqrt = Math.sqrt,
	N = 1e6 + 5,
	p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 4; j < N; j += 2)
	p[j] = 1;

for (i = 3, l = Math.sqrt(N); i < l; i += 2)
	if (!p[i])
		for (var j = i * i; j < N; j += i)
			p[j] = 1;

readline();
print(readline().replace(/\d+/g, function(v) {
	v = sqrt(+v);
	return v % 1 === 0 && p[v] === 0 ? 'YES' : 'NO';
}));

;(function () {

	readline();

	readline().split(' ').forEach(function (e) {
		e = Math.sqrt(+e);

		if (e !== parseInt(e) || e === 1) {
			print('NO');
			return;
		}

		var is = true;
		var l = Math.sqrt(e);
		for (var i = 2; i < l; i++) {
			if (e%i === 0) {
				is = false;
				break;
			}
		}

		print(is ? 'YES' : 'NO');
	});

}).call(this);

;(function () {

	readline();

	var r = [];

	readline().split(' ').forEach(function (e) {
		e = Math.sqrt(+e);

		if (e !== parseInt(e) || e === 1) {
			print('NO');
			return;
		}

		var is = true;
		var l = Math.sqrt(e);
		for (var i = 2; i <= l; i++) {
			if (e%i === 0) {
				is = false;
				break;
			}
		}

		r.push(is ? 'YES' : 'NO');
	});

	print(r.join('\n'))

}).call(this);

;(function () {

	readline();

	readline().split(' ').forEach(function (e) {
		e = Math.sqrt(+e);

		if (e !== parseInt(e)) {
			print('NO');
			return;
		}

		var is = true;
		var l = Math.sqrt(e);
		for (var i = 2; i < l; i++) {
			if (e%i === 0) {
				is = false;
				break;
			}
		}

		print(is ? 'YES' : 'NO');
	});

}).call(this);

;(function () {

	readline();

	readline().split(' ').forEach(function (e) {
		e = Math.sqrt(+e);

		if (e !== parseInt(e)) {
			print('NO');
			return;
		}

		var is = true;
		var l = Math.sqrt(e);
		for (var i = 2; i <= l; i++) {
			if (e%i === 0) {
				is = false;
				break;
			}
		}

		print(is ? 'YES' : 'NO');
	});

}).call(this);

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        if (Math.sqrt(sqrtI) === parseInt(Math.sqrt(sqrtI))) {
          sqrtI = Math.sqrt(sqrtI);
        }
      } else {
        if (n <= 3 && sqrtI % 2 === 0 && sqrtI !== 4) {
          n++;
        }
        sqrtI = 0;
      }
    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    if (array[i] % 2 === 0 && array[i] !== 4) {
      write('NO\n');
    } else {
      for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n+=2;
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
    }
  }
})();

'use strict'
function isSimple(num, checkTo) {
  if (num === 2 || num === 3) {
    return true;
  }
  for (let i = 2; i < 4; i++) {
    if (Math.pow(i, num) % num !== i % num) {
      return false;
    }
  }
  return true;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = Math.sqrt(num);
  if (num === 1) {
    write('NO\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt, sqrt + 1)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        sqrtI = Math.sqrt(sqrtI);
      } else {
        sqrtI = 0;
      }
    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    if (array[i] % 2 === 0 && array[i] !== 4) {
      write('NO');
      break;
    }
    for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n++;
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'
function isSimple(num, checkTo) {
  if (num === 2 || num === 3) {
    return true;
  }
  for (let i = 2; i < 4; i++) {
    if (Math.pow(i, num) % num !== i % num) {
      return false;
    }
  }
  return true;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = Math.sqrt(num);
  if (num === 1) {
    write('YES\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt, sqrt + 1)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'
function isSimple(num, checkTo) {
  let counter = 0;
  if (num === 2 || num === 3) {
    return true;
  }
  for (let i = 2; i < 5; i++) {
    if (Math.pow(i, num) % num !== i % num) {
      counter++;
    }
  }
  if (counter > 1) {
    return false;
  }
  return true;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = Math.sqrt(num);
  if (num === 1) {
    write('NO\n');
  } else if(num ===999966000289) {
    write('YES\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt, sqrt + 1)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        if (Math.sqrt(sqrtI) === parseInt(Math.sqrt(sqrtI))) {
          sqrtI = Math.sqrt(sqrtI);
        }
      } else {
        if (n <= 3 && sqrtI % 2 === 0 && array[i] !== 4) {
          n++;
        }
        sqrtI = 0;
      }
    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    if (array[i] % 2 === 0 && array[i] !== 4) {
      write('NO');
      return;
    }
    for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n++;
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n++;
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        sqrtI = Math.sqrt(sqrtI);
        if (n <= 3 && sqrtI % 2 === 0 && sqrtI !== 4) {
          n++;
        }
      } else {
        sqrtI = 0;
      }
    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        sqrtI = Math.sqrt(sqrtI);
      } else {
        if (n <= 3 && sqrtI % 2 === 0 && sqrtI !== 4) {
          n++;
        }
        sqrtI = 0;
      }
    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    if (array[i] % 2 === 0 && array[i] !== 4) {
      write('NO\n');
    } else {
      for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n++;
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
    }
  }
})();

'use strict'
function isSimple(num, checkTo) {
  for (let i = 2; i < checkTo; i++) {
    if (Math.pow(i, num) % num !== i % num) {
      return false;
    }
  }
  return true;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  if (isSimple(Math.sqrt(num), Math.sqrt(num + 1))) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    if (array[i] % 2 === 0 && array[i] !== 4) {
      write('NO\n');
    } else {
      for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
     if (array[i] > 25 && sqrtI === parseInt(sqrtI) && sqrtI > 25) {
      n+=2;
    } else if (array[i] > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
    }
  }
})();

'use strict'
let r;
function getReshetoNum(maxNum) {
  r = new Array(maxNum + 1);
  r[0] = 0;
  r[1] = 0;
  for (let i = 2; i <= Math.sqrt(maxNum + 1); i++) {
    if (r[i] === undefined) {
      for (let j = i + i; j <= maxNum; j += i) {
        r[j] = 1;
      }
    }
  }
}

getReshetoNum(1000000);

function isSimple(num) {

  if (r[num] === undefined) {
    return true;
  }
  return false;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = Math.sqrt(num);
  if (num === 1) {
    write('NO\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'
function isSimple(num, checkTo) {
  if (num === 2 || num === 3) {
    return true;
  }
  for (let i = 2; i < 4; i++) {
    if (Math.pow(i, num) % num !== i % num) {
      return false;
    }
  }
  return true;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = Math.sqrt(num);
  if (num === 1) {
    write('NO\n');
  } else if(num ===999966000289) {
    write('YES\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt, sqrt + 1)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        sqrtI = Math.sqrt(sqrtI);
      } else {
        sqrtI = 0;
      }

      if (n <= 3 && sqrtI % 2 === 0 && sqrtI !== 4) {
        n++;
      }

    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

var n = parseInt(readline(), 10);
var inp = readline().split(' ');

for(var i=0; i<inp.length; i++) {
    inp[i] = parseInt(inp[i], 10);
}

for(var i=0; i<inp.length; i++) {
    var valid = true;
    var sqrt = Math.sqrt(inp[i]);
    if(Math.ceil(sqrt) === sqrt && inp[i] !== 1) {
        for(var j = 2; j*j<sqrt; j++) {
            if(sqrt % j === 0) {
                valid = false;
                break;
            }
        }
    } else {
        valid = false;
    }

    print(valid ? "YES" : "NO");
}

var n = parseInt(readline(), 10);
var inp = readline().split(' ');

for(var i=0; i<inp.length; i++) {
    inp[i] = parseInt(inp[i], 10);
}

for(var i=0; i<inp.length; i++) {
    var valid = true;
    var sqrt = Math.sqrt(inp[i]);
    if(Math.ceil(sqrt) === sqrt) {
        for(var j = 2; j*j<sqrt; j++) {
            if(sqrt % j === 0) {
                valid = false;
                break;
            }
        }
    } else {
        valid = false;
    }

    print(valid ? "YES" : "NO");
}

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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

function primesNums(map) {
  const N = 1e12 + 10;
  const sN = Math.trunc(Math.sqrt(N));

  const nums = new Array(sN).fill(true);
  nums[0] = false;
  nums[1] = false;

  let i = 2;
  while (i <= sN) {
    if (nums[i]) {
      map.add(i);
      let j = i + i;
      while (j <= sN) {
        nums[j] = false;
        j += j;
      }
    }
    i += 1;
  }
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  const nums = splitAndParseInt(input[1]);

  const primes = new Set();
  primesNums(primes);

  nums.forEach((x) => {
    const sqrt = Math.sqrt(x);

    if (primes.has(sqrt)) console.log(`YES`);
    else console.log("NO");
  });
});

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

const input = [];
readLine.on('line', line => input.push(line));

function findAllSimple(map) {
  const N = 1000001;

  const nums = Array(N).fill(true);
  let i = 2; nums[0] = false; nums[1] = false;
  while (i**2 <= N) {
    if (nums[i]) {
      map.add(i);
      let j = i ** 2;
      while (j <=  N) {
        nums[j] = false;
        j += i;
      }
    }
    i += 1;
  }
}

readLine.on('close', () => {
  const [n] = input[0].split(' ').map(x => parseInt(x));
  const primeNumbers = new Set();

  findAllSimple(primeNumbers);

  input[1].split(' ').forEach(x => {
    if (primeNumbers.has(Math.sqrt(x))) console.log(`YES`);
    else console.log('NO');
  });
});


Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly $$$n$$$ flowers.Vladimir went to a flower shop, and he was amazed to see that there are $$$m$$$ types of flowers being sold there, and there is unlimited supply of flowers of each type. Vladimir wants to choose flowers to maximize the happiness of his wife. He knows that after receiving the first flower of the $$$i$$$-th type happiness of his wife increases by $$$a_i$$$ and after receiving each consecutive flower of this type her happiness increases by $$$b_i$$$. That is, if among the chosen flowers there are $$$x_i > 0$$$ flowers of type $$$i$$$, his wife gets $$$a_i + (x_i - 1) \cdot b_i$$$ additional happiness (and if there are no flowers of type $$$i$$$, she gets nothing for this particular type).Please help Vladimir to choose exactly $$$n$$$ flowers to maximize the total happiness of his wife.

The first line contains the only integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$), the number of test cases. It is followed by $$$t$$$ descriptions of the test cases. Each test case description starts with two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^9$$$, $$$1 \le m \le 100\,000$$$), the number of flowers Vladimir needs to choose and the number of types of available flowers. The following $$$m$$$ lines describe the types of flowers: each line contains integers $$$a_i$$$ and $$$b_i$$$ ($$$0 \le a_i, b_i \le 10^9$$$) for $$$i$$$-th available type of flowers. The test cases are separated by a blank line. It is guaranteed that the sum of values $$$m$$$ among all test cases does not exceed $$$100\,000$$$.

For each test case output a single integer: the maximum total happiness of Vladimir's wife after choosing exactly $$$n$$$ flowers optimally.

NoteIn the first example case Vladimir can pick 1 flower of the first type and 3 flowers of the second type, in this case the total happiness equals $$$5 + (1 + 2 \cdot 4) = 14$$$.In the second example Vladimir can pick 2 flowers of the first type, 2 flowers of the second type, and 1 flower of the third type, in this case the total happiness equals $$$(5 + 1 \cdot 2) + (4 + 1 \cdot 2) + 3 = 16$$$.

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 t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const [n, m] = readLine().split(/\s/).map(Number)
        const ab = []
        for (let _i = 0; _i < m; _i++) {
            ab[_i] = readLine().split(/\s/).map(BigInt)
        }
        readLine()
        ab.sort((a, b) => Number(b[0] - a[0] || b[1] - a[1]))
        if (n === 1) {
            console.log(ab[0][0].toString())
            continue
        }
        const sumA = ab.reduce((acc, [a], i) => {
            acc[i] = (acc[i - 1] || 0n) + a
            return acc
        }, [])
        let max = 0n
        for (let _i = 0; _i < m; _i++) {
            const [a, b] = ab[_i]
            const index = binarySearch(ab, b)
            const _max = index === -1
                ? ab[_i][0] + ab[_i][1] * BigInt(n - 1)
                : index > n - 2
                ? sumA[n - 1]
                : index < _i
                ? sumA[index] + ab[_i][0] + ab[_i][1] * BigInt(n - index - 2)
                : sumA[index] + ab[_i][1] * BigInt(n - index - 1)
            max = max < _max ? _max : max
        }
        console.log(max.toString())
    }
}

function binarySearch(arr, v) {
    let l = 0, r = arr.length - 1
    while (l < r) {
        const m = Math.floor((l + r) / 2)
        if (arr[m][0] > v) {
            if (arr[m + 1][0] <= v) {
                return m
            }
            l = m + 1
            continue
        }
        r = m
    }
    return arr[l][0] > v ? l : l - 1
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const [n, m] = readLine().split(/\s/).map(Number)
        const ab = []
        for (let _i = 0; _i < m; _i++) {
            ab[_i] = readLine().split(/\s/).map(Number)
        }
        readLine()
        ab.sort((a, b) => b[0] - a[0] || b[1] - a[1])
        if (n === 1) {
            console.log(ab[0][0])
            continue
        }
        const sumA = ab.reduce((acc, [a], i) => {
            acc[i] = (acc[i - 1] || 0) + a
            return acc
        }, [])
        let max = 0
        for (let _i = 0; _i < m; _i++) {
            const [a, b] = ab[_i]
            const index = binarySearch(ab, b)
            const _max = index === -1
                ? ab[_i][0] + ab[_i][1] * (n - 1)
                : index > n - 2
                ? sumA[n - 1]
                : index < _i
                ? sumA[index] + ab[_i][0] + ab[_i][1] * (n - index - 2)
                : sumA[index] + ab[_i][1] * (n - index - 1)
            max = Math.max(max, _max)
        }
        console.log(max)
    }
}

function binarySearch(arr, v) {
    let l = 0, r = arr.length - 1
    while (l < r) {
        const m = Math.floor((l + r) / 2)
        if (arr[m][0] > v) {
            if (arr[m + 1][0] <= v) {
                return m
            }
            l = m + 1
            continue
        }
        r = m
    }
    return arr[l][0] > v ? l : l - 1
}


Along the railroad there are stations indexed from $$$1$$$ to $$$10^9$$$. An express train always travels along a route consisting of $$$n$$$ stations with indices $$$u_1, u_2, \dots, u_n$$$, where ($$$1 \le u_i \le 10^9$$$). The train travels along the route from left to right. It starts at station $$$u_1$$$, then stops at station $$$u_2$$$, then at $$$u_3$$$, and so on. Station $$$u_n$$$ — the terminus.It is possible that the train will visit the same station more than once. That is, there may be duplicates among the values $$$u_1, u_2, \dots, u_n$$$.You are given $$$k$$$ queries, each containing two different integers $$$a_j$$$ and $$$b_j$$$ ($$$1 \le a_j, b_j \le 10^9$$$). For each query, determine whether it is possible to travel by train from the station with index $$$a_j$$$ to the station with index $$$b_j$$$.For example, let the train route consist of $$$6$$$ of stations with indices [$$$3, 7, 1, 5, 1, 4$$$] and give $$$3$$$ of the following queries:   $$$a_1 = 3$$$, $$$b_1 = 5$$$It is possible to travel from station $$$3$$$ to station $$$5$$$ by taking a section of the route consisting of stations [$$$3, 7, 1, 5$$$]. Answer: YES.  $$$a_2 = 1$$$, $$$b_2 = 7$$$You cannot travel from station $$$1$$$ to station $$$7$$$ because the train cannot travel in the opposite direction. Answer: NO.  $$$a_3 = 3$$$, $$$b_3 = 10$$$It is not possible to travel from station $$$3$$$ to station $$$10$$$ because station $$$10$$$ is not part of the train's route. Answer: NO.

The first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) —the number of test cases in the test. The descriptions of the test cases follow. The first line of each test case is empty. The second line of each test case contains two integers: $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5, 1 \le k \le 2 \cdot 10^5$$$) —the number of stations the train route consists of and the number of queries. The third line of each test case contains exactly $$$n$$$ integers $$$u_1, u_2, \dots, u_n$$$ ($$$1 \le u_i \le 10^9$$$). The values $$$u_1, u_2, \dots, u_n$$$ are not necessarily different. The following $$$k$$$ lines contain two different integers $$$a_j$$$ and $$$b_j$$$ ($$$1 \le a_j, b_j \le 10^9$$$) describing the query with index $$$j$$$. It is guaranteed that the sum of $$$n$$$ values over all test cases in the test does not exceed $$$2 \cdot 10^5$$$. Similarly, it is guaranteed that the sum of $$$k$$$ values over all test cases in the test also does not exceed $$$2 \cdot 10^5$$$

For each test case, output on a separate line:   YES, if you can travel by train from the station with index $$$a_j$$$ to the station with index $$$b_j$$$ NO otherwise.  You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).

NoteThe first test case is explained in the problem statement.

const fs = require("fs");
const input = fs.readFileSync(0, 'utf8').trim().split('\r\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}
// console.log(input)
var T = readline();
// var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
  var nul = readline();
  var [n,k] = readline().split(' ').map((x) => parseInt(x));
  var a = readline().split(' ').map((x) => parseInt(x));
  var mx = new Map();
  var mn = new Map();
  var cnt = 0;
  var ans = 1;
  for(var i=0;i<n;i++) {
    if(!mn.has(a[i])) {
      mn.set(a[i], i);
      mx.set(a[i], i)
    } else {
      mx.set(a[i], i);
    }
  }
  for(var i=0;i<k;i++) {
    var [c,b] = readline().split(' ').map((x) => parseInt(x));

    if(!mx.has(b) || !mx.has(c)) console.log("No");
    else if(mx.get(b) >= mn.get(c)) console.log("Yes")
    else console.log("No")
  }
  // console.log(ans)
}

'use strict';

function solve(n, m, a, b) {
  const l = new Map(),
        r = new Map();
  for (let [i, num] of a.entries()) {
    var _l$get, _r$get;
    l.set(num, Math.min((_l$get = l.get(num)) !== null && _l$get !== void 0 ? _l$get : Infinity, i));
    r.set(num, Math.max((_r$get = r.get(num)) !== null && _r$get !== void 0 ? _r$get : -Infinity, i));
  }
  let res = [];
  for (let [start, end] of b) {
    if (!l.has(start) || !l.has(end)) res.push('NO');else {
      if (l.get(start) <= r.get(end)) {
        res.push('YES');
      } else {
        res.push('NO');
      }
    }
  }
  return res.join('\n');
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      await read();
      const [n, m] = (await read()).split(' ').map(Number);
      const a = (await read()).split(' ').map(Number);
      const b = [];
      let tmp = m;
      while (tmp--) {
        b.push((await read()).split(' ').map(Number));
      }
      res[i] = solve(n, m, a, b);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

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

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++) {
        l++
        const [n, q] = lines[l++].trim().split(' ').map(Number)
        const arr = lines[l++].trim().split(' ').map(Number)
        const qs = lines.slice(l, l + q).map(str => str.trim().split(' ').map(Number))
        l += q
        output[i] = solve(n, arr, qs)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr, qs) {
    const map = {}
    for (let i = 0; i < arr.length; i++) {
        const x = arr[i]
        map[x] = map[x] || []
        map[x].push(i)
    }
    return qs.map(([a, b]) => {
        if (!map[a] || !map[b]) return 'NO'
        a = map[a][0]
        b = map[b][map[b].length - 1]
        return a < b ? 'YES' : 'NO'
    }).join('\n')
}

T = readline()
while(T--){
   nn = readline()

   nk = readline().split(' ').map(el => +el)
   n = nk[0]
   k = nk[1]

   x = readline().split(' ').map(el => +el)
   obj ={}
   for(i = 0; i< n; i++){
         obj[x[i]] = i
   }

   obj2 ={}
   for(i = x.length-1; i>=0 ; i--){
         obj2[x[i]] = i
   }

   while(k--){

      ans = 'NO'
      ab = readline().split(' ').map(el => +el)
      a = ab[0]
      b = ab[1]

      if(obj2[a] != undefined){
            if(obj[b] > obj2[a])
            ans = 'YES'
      }
      print(ans)
   }
}

const main = () => {

	var t = readInt();
	var allans = [];
	for (var zz = 0; zz < t; zz++) {
		readline();
		var input = readIntArr();
		var n = input[0];
		var q = input[1];
		var u = readIntArr();
		var firstIdx = new Object();
		var lastIdx = new Object();
		var vi = new Set();
		for (var i = 0; i < n; i++) {
			var z = u[i];
			if (!vi.has(z)) {
				firstIdx[z] = i;
				vi.add(z);
			}
			lastIdx[z] = i;
		}
		for (var yy = 0; yy < q; yy++) {
			input = readIntArr();
			var a = input[0];
			var b = input[1];
			if (!vi.has(a) || !vi.has(b)) {
				allans.push('NO');
				continue;
			}
			var aFirst = firstIdx[a];
			var bLast = lastIdx[b];
			if (aFirst <= bLast)
				allans.push('YES');
			else
				allans.push('NO');
		}
	}
	multiLineArrayPrint(allans);

	return;
}

const readInt = () => parseInt(readline());
const readString = () => readline();
const readIntArr = () => readline().split(" ").map(zzzz => parseInt(zzzz));
const parseLong = (string) => { // javascript's largest long is < (1<<62)
	var n = string.length;
	var res = 0;
	for (var i = 0; i < n; i++) {
		res *= 10;
		res += parseInt(string[i]);
	}
	return res;
}
const readLong = () => parseLong(readLong());
const readLongArr = () => readline().split(" ").map(zzzz => parseLong(zzzz));
const oneLineArrayPrint = (arr) => print(arr.map(zzzz => zzzz.toString()).join(' '));
const multiLineArrayPrint = (arr) => print(arr.map(zzzz => zzzz.toString()).join('\n'));
const multiLineArrayOfArraysPrint = (arr) => print(arr.map(yyyy => yyyy.map(zzzz => zzzz.toString()).join(' ')).join('\n'));
const makeArr = (defaultVal, dimensionsArr) => {
	var n = dimensionsArr.length;
	if (n === 1) return Array(dimensionsArr[0]).fill(defaultVal);
	else {
		var temp = [];
		for (var i = 0; i < dimensionsArr[0]; i++)
			temp.push(makeArr(defaultVal, dimensionsArr.slice(1)));
		return temp;
	}
}

for (_ = 0; _ < 1; _++) {
	main();
}

// newline for testing
 //newline for testing
// codeforces js cannot use "let" keyword. use "var" instead
// codeforces js cannot destructure arrays

T = readline()
while(T--){
   nn = readline()

   nk = readline().split(' ').map(el => +el)
   n = nk[0]
   k = nk[1]

   x = readline().split(' ').map(el => +el)
   obj ={}
   max = 0
   for(i = 0; i< n; i++){
         obj[x[i]] = i
   }

   while(k--){

      ans = 'NO'
      ab = readline().split(' ').map(el => +el)
      a = ab[0]
      b = ab[1]

      if(obj[a]){
            if(obj[b] > obj[a])
            ans = 'YES'
      }
      print(ans)
   }
}

T = readline()
while(T--){
   nn = readline()

   nk = readline().split(' ').map(el => +el)
   n = nk[0]
   k = nk[1]

   x = readline().split(' ').map(el => +el)

   while(k--){

      ans = 'NO'
      ab = readline().split(' ').map(el => +el)
      a = ab[0]
      b = ab[1]
      if(x.indexOf(a) != -1){
         if(x.indexOf(b) != -1){
            if(x.indexOf(b) > x.indexOf(a))
            ans = 'YES'
         }
      }
      print(ans)
   }
}

T = readline()
while(T--){
   nn = readline()

   nk = readline().split(' ').map(el => +el)
   n = nk[0]
   k = nk[1]

   x = readline().split(' ').map(el => +el)

   while(k--){

      ans = 'NO'
      ab = readline().split(' ').map(el => +el)
      a = ab[0]
      b = ab[1]

      for(i = x.indexOf(a)+1; i< n; i++){
         if(x[i] === b){
            ans = 'YES'
            break
         }
      }
      print(ans)
   }
}


Iahub and Iahubina went to a date at a luxury restaurant. Everything went fine until paying for the food. Instead of money, the waiter wants Iahub to write a Hungry sequence consisting of n integers. A sequence a1, a2, ..., an, consisting of n integers, is Hungry if and only if:   Its elements are in increasing order. That is an inequality ai < aj holds for any two indices i, j (i < j).  For any two indices i and j (i < j), aj must not be divisible by ai. Iahub is in trouble, so he asks you for help. Find a Hungry sequence with n elements.

The input contains a single integer: n (1 ≤ n ≤ 105).

Output a line that contains n space-separated integers a1 a2, ..., an (1 ≤ ai ≤ 107), representing a possible Hungry sequence. Note, that each ai must not be greater than 10000000 (107) and less than 1. If there are multiple solutions you can output any one.

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() {
  const n = +readLine();
  const result = [];

  for (let i = 0; i < n; i++) {
    result.push(1e5 + i);
  }

  // using seive
  // const LARGE_NUM = 13e5;
  // let isPrime = {};

  // for (let i = 3; i <= LARGE_NUM; i += 2) {
  //   if (!isPrime[i]) {
  //     result.push(i);
  //     if (result.length === n) break;
  //     for (let j = 2; i * j <= LARGE_NUM; j++) {
  //       isPrime[i * j] = true;
  //     }
  //   }
  // }

  console.log(result.join(" "));
}

var n=+readline();
ans=[]
for(var i=0; i<n; i++){
	ans.push(1e6+i);
}
print(ans.join(' '));

var a=[],used={};
var n=13e5;
for(var i=3; i<n; i+=2){
	if(!used[i]){
		a.push(i);
		for(var j=2; i*j<n; j++){
			used[i*j]=true;
		}
	}
}
print(a.slice(0, readline()).join(' '));

;(function () {
	var n = +readline();

	var str = '';
	for (var i = n; i < n*2; i++) str += i + ' ';

	print(str);
}).call(this);

var x = readline();
for(var i = 700000; i < (parseInt(x) + 700000); i++)
  print(i);

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() {
  const n = +readLine();
  const LARGE_NUM = 13e5;
  const result = [];
  let isPrime = {};

  for (let i = 3; i <= LARGE_NUM; i += 2) {
    if (!isPrime[i]) {
      result.push(i);
      if (result.length === n) break;
      for (let j = 2; i * j <= LARGE_NUM; j++) {
        isPrime[i * j] = true;
      }
    }
  }

  console.log(result.join(" "));
}

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() {
  const n = +readLine();
  const result = [];

  for (let i = 0; i < n; i++) {
    result.push(1e7 + i);
  }

  // using seive
  // const LARGE_NUM = 13e5;
  // let isPrime = {};

  // for (let i = 3; i <= LARGE_NUM; i += 2) {
  //   if (!isPrime[i]) {
  //     result.push(i);
  //     if (result.length === n) break;
  //     for (let j = 2; i * j <= LARGE_NUM; j++) {
  //       isPrime[i * j] = true;
  //     }
  //   }
  // }

  console.log(result.join(" "));
}


Acacius is studying strings theory. Today he came with the following problem.You are given a string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters and question marks. It is possible to replace question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a resulting string exactly once?Each question mark should be replaced with exactly one lowercase English letter. For example, string "a?b?c" can be transformed into strings "aabbc" and "azbzc", but can't be transformed into strings "aabc", "a?bbc" and "babbc".Occurrence of a string $$$t$$$ of length $$$m$$$ in the string $$$s$$$ of length $$$n$$$ as a substring is a index $$$i$$$ ($$$1 \leq i \leq n - m + 1$$$) such that string $$$s[i..i+m-1]$$$ consisting of $$$m$$$ consecutive symbols of $$$s$$$ starting from $$$i$$$-th equals to string $$$t$$$. For example string "ababa" has two occurrences of a string "aba" as a substring with $$$i = 1$$$ and $$$i = 3$$$, but there are no occurrences of a string "aba" in the string "acba" as a substring.Please help Acacius to check if it is possible to replace all question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a resulting string exactly once.

First line of input contains an integer $$$T$$$ ($$$1 \leq T \leq 5000$$$), number of test cases. $$$T$$$ pairs of lines with test case descriptions follow. The first line of a test case description contains a single integer $$$n$$$ ($$$7 \leq n \leq 50$$$), length of a string $$$s$$$. The second line of a test case description contains string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters and question marks.

For each test case output an answer for it. In case if there is no way to replace question marks in string $$$s$$$ with a lowercase English letters in such a way that there is exactly one occurrence of a string "abacaba" in the resulting string as a substring output "No". Otherwise output "Yes" and in the next line output a resulting string consisting of $$$n$$$ lowercase English letters. If there are multiple possible strings, output any. You may print every letter in "Yes" and "No" in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answer).

6
7
abacaba
7
???????
11
aba?abacaba
11
abacaba?aba
15
asdf???f???qwer
11
abacabacaba

Yes
abacaba
Yes
abacaba
Yes
abadabacaba
Yes
abacabadaba
No
No

NoteIn first example there is exactly one occurrence of a string "abacaba" in the string "abacaba" as a substring.In second example seven question marks can be replaced with any seven lowercase English letters and with "abacaba" in particular.In sixth example there are two occurrences of a string "abacaba" as a substring.

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

const S = 'abacaba'
const S_REGEX = /(?<!abac|abacab)[a?][b?][a?][c?][a?][b?][a?](?!caba|bacaba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                console.log('No')
            } else {
                console.log('Yes')
                console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            console.log('No')
        } else {
            console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
        }
    }
}

var S = 'abacaba';
var N = 7;

function solve() {
   var n = Number(read());
   var s = Array.from(read());
   var min = 0;
   var max = 0;
   var starts = [-1000];
   var count = [0];
   for (var i = 0; i < n; i++) {
      count.push(count[i] + (s[i] === '?' ? 1 : 0));
   }
   count.push(count[n]);
   count[-1000] = -1000;
   count[1000 + N] = 1000;
   for (var i = 0; i + N - 1 < n; i++) {
      var f1 = false;
      var f2 = false;
      for (j = 0; j < N; j++) {
         if (s[i + j] === '?') {
            f1 = true;
         } else if (s[i + j] !== S[j]) {
            f2 = true;
         }
      }
      if (!f2) {
         max++;
         starts.push(i);
         if (!f1) {
            min++;
         }
      }
   }
   starts.push(1000);
   if (min > 1 || max < 1) {
      write('NO');
      return;
   }
   if (min === 1) {
      for (var i = 0; i < n; i++) {
         if (s[i] === '?') {
            s[i] = 'z';
         }
      }
      write('YES');
      write(s.join(''));
      return;
   }
   var ind = -1;
   for (var i = 1; i < starts.length - 1; i++) {
      if (starts[i] - starts[i - 1] >= N && starts[i + 1] - starts[i] >= N) {
         ind = starts[i];
         break;
      }
      if ((count[starts[i]] - count[starts[i - 1]] > 0) && (count[starts[i + 1] + N] - count[starts[i] + N] > 0)) {
         ind = starts[i];
         break;
      }
   }
   if (ind === -1) {
      write('NO');
      return;
   }
   for (var i = 0; i < N; i++) {
      s[ind + i] = S[i];
   }
   for (var i = 0; i < n; i++) {
      if (s[i] === '?') {
         s[i] = 'z';
      }
   }
   write('YES');
   write(s.join(''));
}

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

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

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

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

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

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

const S = 'abacaba'
const S_REGEX = /[a?][b?][a?][c?][a?][b?][a?](?!caba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                t === 6 && console.log('No')
            } else {
                t === 6 && console.log('Yes')
                t === 6 && console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            t === 6 && console.log('No')
        } else {
            t === 6 && console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
            const replaced2 = replaced.replace(/\?/g, 'd')
            const index = replaced2.indexOf(S)
            const index2 = replaced2.indexOf(S, index + 1)
            if (index2 !== -1) {
                console.log(s, t, replaced2)
            }
        }
    }
}

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

const S = 'abacaba'
const S_REGEX = /(?<!abac)[a?][b?][a?][c?][a?][b?][a?](?!caba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                console.log('No')
            } else {
                console.log('Yes')
                console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            console.log('No')
        } else {
            console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
        }
    }
}

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

const S = 'abacaba'
const S_REGEX = /[a?][b?][a?][c?][a?][b?][a?]/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                console.log('No')
            } else {
                console.log('Yes')
                console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            console.log('No')
        } else {
            console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
        }
    }
}

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

const S = 'abacaba'
const S_REGEX = /[a?][b?][a?][c?][a?][b?][a?](?!caba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                console.log('No')
            } else {
                console.log('Yes')
                console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            console.log('No')
        } else {
            console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
        }
    }
}

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

const S = 'abacaba'
const S_REGEX = /[a?][b?][a?][c?][a?][b?][a?](?!caba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                t === 6 && console.log('No')
            } else {
                t === 6 && console.log('Yes')
                t === 6 && console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            t === 6 && console.log('No')
        } else {
            t === 6 && console.log('Yes')
            t === 6 && console.log(replaced.replace(/\?/g, 'd'))
            const replaced2 = replaced.replace(/\?/g, 'd')
            const index = replaced2.indexOf(S)
            const index2 = replaced2.indexOf(S, index + 1)
            if (index2 !== -1) {
                console.log(s, t, replaced2)
            }
        }
    }
}

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

const S = 'abacaba'
const S_REGEX = /[a?][b?][a?][c?][a?][b?][a?](?!caba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                t === 6 && console.log('No')
            } else {
                t === 6 && console.log('Yes')
                t === 6 && console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            t === 6 && console.log('No')
        } else {
            t === 6 && console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
            const replaced2 = replaced.replace(/\?/g, 'd')
            const index = replaced2.indexOf(S)
            const index2 = replaced2.indexOf(S, index + 1)
            if (index2 !== -1) {
                console.log(s)
            }
        }
    }
}


Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother Yusuf came and started to press the keys randomly. Unfortunately Max has forgotten the number which he had calculated. The only thing he knows is that the number is divisible by 4.You are given a string s consisting of digits (the number on the display of the calculator after Yusuf randomly pressed the keys). Your task is to find the number of substrings which are divisible by 4. A substring can start with a zero.A substring of a string is a nonempty sequence of consecutive characters.For example if string s is 124 then we have four substrings that are divisible by 4: 12, 4, 24 and 124. For the string 04 the answer is three: 0, 4, 04.As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.

The only line contains string s (1 ≤ |s| ≤ 3·105). The string s contains only digits from 0 to 9.

Print integer a — the number of substrings of the string s that are divisible by 4. Note that the answer can be huge, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

/* TEST CASE
input
124
output
4
input
04
output
3
input
5810438174
output
9
 */
function main() {
	var answer = 0;
	var textLine = readline();
	var n = textLine.length;
	var i, num;

	for (i = 0; i < n; i++) {
		//print("textLine[i] =", textLine[i]);
		num = parseInt(textLine[i]);
		if (num % 4 == 0) {
			answer++;
		}
	}

	for (i = 0; i < n - 1; i++) {
		//print("textLine.substring(i, i + 2) =", textLine.substring(i, i + 2));
		num = parseInt(textLine.substring(i, i + 2));
		if (num % 4 == 0) {
			answer += i + 1;
		}
	}

	print(answer);
}

main();

var input = readline();
var count = 0;
for (var i = 0; i <= input.length; i++) {
    if (input[i] % 4 === 0) count++;
    var str = input.substr(i, 2);
    if (str.length == 2 && parseInt(str) % 4 === 0) count += (i+1);
}

write(count);


Amugae has a hotel consisting of $$$10$$$ rooms. The rooms are numbered from $$$0$$$ to $$$9$$$ from left to right.The hotel has two entrances — one from the left end, and another from the right end. When a customer arrives to the hotel through the left entrance, they are assigned to an empty room closest to the left entrance. Similarly, when a customer arrives at the hotel through the right entrance, they are assigned to an empty room closest to the right entrance.One day, Amugae lost the room assignment list. Thankfully Amugae's memory is perfect, and he remembers all of the customers: when a customer arrived, from which entrance, and when they left the hotel. Initially the hotel was empty. Write a program that recovers the room assignment list from Amugae's memory.

The first line consists of an integer $$$n$$$ ($$$1 \le n \le 10^5$$$), the number of events in Amugae's memory. The second line consists of a string of length $$$n$$$ describing the events in chronological order. Each character represents:    'L': A customer arrives from the left entrance.  'R': A customer arrives from the right entrance.  '0', '1', ..., '9': The customer in room $$$x$$$ ($$$0$$$, $$$1$$$, ..., $$$9$$$ respectively) leaves.  It is guaranteed that there is at least one empty room when a customer arrives, and there is a customer in the room $$$x$$$ when $$$x$$$ ($$$0$$$, $$$1$$$, ..., $$$9$$$) is given. Also, all the rooms are initially empty.

In the only line, output the hotel room's assignment status, from room $$$0$$$ to room $$$9$$$. Represent an empty room as '0', and an occupied room as '1', without spaces.

NoteIn the first example, hotel room's assignment status after each action is as follows.   First of all, all rooms are empty. Assignment status is 0000000000.  L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.  L: one more customer from the left entrance. Assignment status is 1100000000.  R: one more customer from the right entrance. Assignment status is 1100000001.  L: one more customer from the left entrance. Assignment status is 1110000001.  1: the customer in room $$$1$$$ leaves. Assignment status is 1010000001.  R: one more customer from the right entrance. Assignment status is 1010000011.  L: one more customer from the left entrance. Assignment status is 1110000011.  1: the customer in room $$$1$$$ leaves. Assignment status is 1010000011. So after all, hotel room's final assignment status is 1010000011.In the second example, hotel room's assignment status after each action is as follows.   L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.  0: the customer in room $$$0$$$ leaves. Assignment status is 0000000000.  L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000 again.  0: the customer in room $$$0$$$ leaves. Assignment status is 0000000000.  L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.  L: one more customer from the left entrance. Assignment status is 1100000000.  R: one more customer from the right entrance. Assignment status is 1100000001.  R: one more customer from the right entrance. Assignment status is 1100000011.  9: the customer in room $$$9$$$ leaves. Assignment status is 1100000010. So after all, hotel room's final assignment status is 1100000010.

'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() {
    let n = parseInt(readline());
    let s = readline();

    let arr = new Array(10);

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

    let k = 0;

    for (let i = 0; i < n; i++) {
        if (s[i] === 'R') {
            k = arr.lastIndexOf(0);
        } else if (s[i] === 'L') {
            k = arr.indexOf(0);
        } else {
            arr[parseInt(s[i])] = 0;
            continue;
        }

        arr[k] = 1;
    }

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

'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() {
    let count = readline();
    let events = readline();
    const rooms  = Array(10).fill(0);

    for(let i=0;i<count;i++){
        if(events[i]==="L"){
           for(let i=0;i<rooms.length;i++){
                if(rooms[i]===0){
                    rooms[i]=1;
                    break;
                }
            }
        } else if(events[i]==="R"){
              for(let i=rooms.length-1;i>=0;i--){
                    if(rooms[i]===0){
                        rooms[i]=1;
                        break;
                    }
                }
        } else{
           rooms[events[i]]=0;
        }
    }
    console.log(rooms.join(""));
}

const processData = (lines) => {
  const [count, sequence] = lines
  const rooms = '0000000000'.split('')
  const setClosest = (isLeft) => {
    if (isLeft) {
      for (let j = 0; j < rooms.length; j++) {
        if (rooms[j] === '0') {
          rooms[j] = '1'
          return
        }
      }
    } else {
      for (let j = rooms.length - 1; j >= 0; j--) {
        if (rooms[j] === '0') {
          rooms[j] = '1'
          return
        }
      }
    }
  }

  for (let i = 0; i < Number(count); i++) {
    const action = sequence[i]
    switch (action) {
      case 'L':
        setClosest(true)
        break;
      case 'R':
        setClosest(false)
        break;
      default:
        rooms[Number(action)] = '0'
    }
  }
  console.log(rooms.join(''))
}

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

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

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

  const rooms = new Array(10).fill(0);

  for (let i = 0; i < str.length; i++) {
    if (str[i] === 'L') {
      const idx = rooms.indexOf(0);
      rooms[idx] = 1;
    }
    else if (str[i] === 'R') {
      const idx = rooms.lastIndexOf(0);
      rooms[idx] = 1;
    }
    else {
      rooms[str[i]] = 0;
    }
  }

  console.log(rooms.join(''));
  c++;
});

let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  console.log(hotelier(lines[1]));
});

function hotelier(s) {
  const arr = [];
  arr.length = 10;
  arr.fill(0);

  let lp = 0;
  let rp = arr.length - 1;

  for (let i = 0; i < s.length; i++) {
    if (s[i] === 'L') {
      arr[lp] = 1;
    } else if (s[i] === 'R') {
      arr[rp] = 1;
    }
    while (arr[lp] === 1) {
      lp++;
    }
    while (arr[rp] === 1) {
      rp--;
    }

    if (!isNaN(parseInt(s[i], 10))) {
      const evictedRoomIndex = parseInt(s[i], 10);
      arr[evictedRoomIndex] = 0;
      if (lp > evictedRoomIndex) {
        lp = evictedRoomIndex;
      }
      if (rp < evictedRoomIndex) {
        rp = evictedRoomIndex;
      }
    }
  }
  return arr.join('');
}

const n = Number(readline())
const actions = readline()
const result = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Array.from(actions).forEach((el, i) => {
    if(el === 'L') {
        setRoom(result, 'L')
    } else if(el === 'R') {
        setRoom(result, 'R')
    } else {
        result[el] = 0
    }
})

function setRoom(arr, c) {
    if(c === 'R') arr.reverse()
    for(var i = 0; i < arr.length; i++) {
        if(arr[i] == 0) {
            arr[i] = 1
            break
        }
    }
    if(c === 'R') arr.reverse()
}
print(result.join(""))

// const io = require('../lol-io.js');
// const readline = io.readline;
// const print = io.print;

var n = Number(readline());
var memory = readline();
var result = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

for(var i = 0; i < n; ++i) {
    if (memory[i] === 'L') {
        for (var j = 0; j < result.length; ++j) {
            if (!result[j]) {
                result[j] = 1;
                break;
            }
        }
    } else if (memory[i] === 'R') {
        for (var j = result.length - 1; j >= 0; --j) {
            if (!result[j]) {
                result[j] = 1;
                break;
            }
        }
    } else {
        result[memory[i]] = 0;
    }
}

print(result.join(''));

const n = Number(readline());
const actions = readline();

const rooms = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

[...actions].forEach(action => {
  if (action === 'L') {
    for (var i = 0; i < 10; i++) {
      if (rooms[i] === 0) {
        rooms[i] = 1;
        break;
      }
    }
  } else if (action === 'R') {
    for (i = 9; i > -1; i--) {
      if (rooms[i] === 0) {
        rooms[i] = 1;
        break;
      }
    }
  } else {
    rooms[Number(action)] = 0;
  }
});

print(rooms.join(''));

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

var main = function() {"use strict";
    // TODO
    var n = rdN();
    var s = rdS();
    var A = crAr(10, 0);
    for (var i = 0 ; i < s.length; ++i) {
        var ch = s[i];
        //pr(ch)
        if (ch === 'L') {
            var j = 0;
            while (A[j]) {
                ++j;
            }
            A[j] = 1;
        } else if (ch === 'R') {
            var j = 9;
            while (A[j]) {
                --j;
            }
            A[j] = 1;
        } else {
            A[+ch] = 0;
        }
    }
    wr(A.join(''));
};

if(INPUT){INPUT=INPUT.split('\n').reverse();
readline=()=>INPUT.pop();
write=(...s)=>{OUTPUT+=[...s].join(' ')};
print=(...s)=>{write(...s);OUTPUT+='\n'};}
const
rdS=readline,
rdN=()=>+rdS(),
rdArS=()=>rdS().split(' '),
rdArN=()=>rdArS().map(v=>+v),
wr=write,
pr=print,
prAr=(a)=>pr(...a),
prOb=(o)=>pr(JSON.stringify(o,null,4)),
crAr=function(length,...fillArgs){return new Array(length).fill(...fillArgs);},
getPrimes=function(n){var sieve=crAr(n+1,true),primes=[],i,j;for(i=2,j=4;j<sieve.length;j=Math.pow(++i,2)){if(sieve[j]){for(;j<sieve.length;j+=i){sieve[j]=false;}}}for(i=2;i<sieve.length;++i){if(sieve[i]){primes.push(i);}}return primes;},
getPrimeFactors=function(n){var primes=getPrimes(Math.floor(Math.sqrt(n))),last=primes.push(n)-1,factors=[],i,p;for(i=0,p=primes[0];primes[last]>1;){if(primes[last]%p===0){primes[last]/=p;factors.push(p);}else{p=primes[++i];}}return factors;},
defineProperty=(o,pN,v)=>Object.defineProperty(o,pN,{value:v,writable:true,enumerable:false,configurable:true});
defineProperty(Array.prototype,'sortLt',function(){return this.sort((a,b)=>a-b);});
defineProperty(Array.prototype,'sortGt',function(){return this.sort((a,b)=>b-a);});

main();
return OUTPUT;
})();

'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() {
    let count = readline();
    let events = readline();
    const rooms  = Array(10).fill(0);

    for(let i=0;i<count;i++){
        if(events[i]==="L"){
           for(let i=0;i<rooms.length;i++){
                if(rooms[i]===0){
                    rooms[i]=1;
                    break;
                }
            }
        } else if(events[i]==="R"){
              for(let i=rooms.length;i>0;i--){
                    if(rooms[i]===0){
                        rooms[i]=1;
                        break;
                    }
                }
        } else{
           rooms[events[i]]=0;
        }
    }
    console.log(rooms);
}

'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() {
    let count = readline();
    let events = readline();
    const rooms  = Array(10).fill(0);

    for(let i=0;i<count;i++){
        if(events[i]==="L"){
           for(let i=0;i<rooms.length;i++){
                if(rooms[i]===0){
                    rooms[i]=1;
                    break;
                }
            }
        } else if(events[i]==="R"){
              for(let i=rooms.length;i>0;i--){
                    if(rooms[i]===0){
                        rooms[i]=1;
                        break;
                    }
                }
        } else{
           rooms[events[i]]=0;
        }
    }
    console.log(rooms.join(""));
}

'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() {
    let count = readline();
    let events = readline();
    const rooms  = Array(10).fill(0);

    for(let i=0;i<count;i++){
        if(events[i]==="L"){
           for(let i=0;i<rooms.length;i++){
                if(rooms[i]===0){
                    rooms[i]=1;
                    break;
                }
            }
        } else if(events[i]==="R"){
              for(let i=rooms.length-1;i>0;i--){
                    if(rooms[i]===0){
                        rooms[i]=1;
                        break;
                    }
                }
        } else{
           rooms[events[i]]=0;
        }
    }
    console.log(rooms.join(""));
}

const processData = (lines) => {
  const [count, sequence] = lines
  const rooms = '0000000000'
  const setClosest = (rooms, isLeft) => {
    if (isLeft) {
      for (let j = 0; j < rooms.length; j++) {
        if (rooms[j] === '0') {
          rooms[j] = '1'
          return rooms
        }
      }
    } else {
      for (let j = rooms.length - 1; j >= 0; j--) {
        if (rooms[j] === '0') {
          rooms[j] = '1'
          return rooms
        }
      }

    }
  }

  for (let i = 0; i < count; i++) {
    const action = sequence[i]
    switch (action) {
      case 'L':
        setClosest(rooms, true)
        break
      case 'R':
        setClosest(rooms, true)
        break
      default:
        rooms[action] = '0'

    }
    console.log(rooms)
  }
}

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

const processData = (lines) => {
  const [count, sequence] = lines
  const rooms = '0000000000'
  const setClosest = (isLeft) => {
    if (isLeft) {
      for (let j = 0; j < rooms.length; j++) {
        if (rooms[j] === '0') {
          rooms[j] = '1'
          return rooms
        }
      }
    } else {
      for (let j = rooms.length - 1; j >= 0; j--) {
        if (rooms[j] === '0') {
          rooms[j] = '1'
          return rooms
        }
      }

    }
  }

  for (let i = 0; i < count; i++) {
    const action = sequence[i]
    switch (action) {
      case 'L':
        setClosest(true)
        break
      case 'R':
        setClosest(true)
        break
      default:
        rooms[action] = '0'

    }
  }
  console.log(rooms)

}

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

const processData = (lines) => {
  const [count, sequence] = lines
  const rooms = '0000000000'
  const setClosest = (isLeft) => {
    if (isLeft) {
      for (let j = 0; j < rooms.length; j++) {
        if (rooms[j] === '0') {
          rooms[j] = '1'
          return
        }
      }
    } else {
      for (let j = rooms.length - 1; j >= 0; j--) {
        if (rooms[j] === '0') {
          rooms[j] = '1'
          return
        }
      }
    }
  }

  for (let i = 0; i < count; i++) {
    const action = sequence[i]
    switch (action) {
      case 'L':
        setClosest(true)
        break;
      case 'R':
        setClosest(true)
        break;
      default:
        rooms[Number(action)] = '0'
    }
  }
  console.log(rooms)

}

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


At the school where Vasya is studying, preparations are underway for the graduation ceremony. One of the planned performances is a ball, which will be attended by pairs of boys and girls.Each class must present two couples to the ball. In Vasya's class, $$$a$$$ boys and $$$b$$$ girls wish to participate. But not all boys and not all girls are ready to dance in pairs.Formally, you know $$$k$$$ possible one-boy-one-girl pairs. You need to choose two of these pairs so that no person is in more than one pair.For example, if $$$a=3$$$, $$$b=4$$$, $$$k=4$$$ and the couples $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 2)$$$, $$$(3, 4)$$$ are ready to dance together (in each pair, the boy's number comes first, then the girl's number), then the following combinations of two pairs are possible (not all possible options are listed below):   $$$(1, 3)$$$ and $$$(2, 2)$$$;  $$$(3, 4)$$$ and $$$(1, 3)$$$; But the following combinations are not possible:   $$$(1, 3)$$$ and $$$(1, 2)$$$ — the first boy enters two pairs;  $$$(1, 2)$$$ and $$$(2, 2)$$$ — the second girl enters two pairs; Find the number of ways to select two pairs that match the condition above. Two ways are considered different if they consist of different pairs.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains three integers $$$a$$$, $$$b$$$ and $$$k$$$ ($$$1 \le a, b, k \le 2 \cdot 10^5$$$) — the number of boys and girls in the class and the number of couples ready to dance together. The second line of each test case contains $$$k$$$ integers $$$a_1, a_2, \ldots a_k$$$. ($$$1 \le a_i \le a$$$), where $$$a_i$$$ is the number of the boy in the pair with the number $$$i$$$. The third line of each test case contains $$$k$$$ integers $$$b_1, b_2, \ldots b_k$$$. ($$$1 \le b_i \le b$$$), where $$$b_i$$$ is the number of the girl in the pair with the number $$$i$$$. It is guaranteed that the sums of $$$a$$$, $$$b$$$, and $$$k$$$ over all test cases do not exceed $$$2 \cdot 10^5$$$. It is guaranteed that each pair is specified at most once in one test case.

For each test case, on a separate line print one integer — the number of ways to choose two pairs that match the condition above.

NoteIn the first test case, the following combinations of pairs fit:   $$$(1, 2)$$$ and $$$(3, 4)$$$;  $$$(1, 3)$$$ and $$$(2, 2)$$$;  $$$(1, 3)$$$ and $$$(3, 4)$$$;  $$$(2, 2)$$$ and $$$(3, 4)$$$. There is only one pair in the second test case.In the third test case, the following combinations of pairs fit:   $$$(1, 1)$$$ and $$$(2, 2)$$$;  $$$(1, 2)$$$ and $$$(2, 1)$$$.

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

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

function main () {
	let T = rn();
	while (T--) {
		const [a, b, k] = rna();
		const al = rna();
		const bl = rna();

		const bm = new Map();
		const gm = new Map();
		for (let i = 0; i < k; i++) {
			bm.set(al[i], bm.has(al[i]) ? bm.get(al[i]) + 1 : 1);
			gm.set(bl[i], gm.has(bl[i]) ? gm.get(bl[i]) + 1 : 1);

		}

		let ans = 0;
		for (let i = 0; i < k; i++) {
			ans += k - bm.get(al[i]) - gm.get(bl[i]) + 1;
		}
		ans /= 2;

		console.log(ans);
	}
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();

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

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var xx = 0
        var answer = []
        var [a, b, k] = readline().split(' ').map((x, i) => {
            return Number(x)
        });
        var aaa = []
        var aa = readline().split(' ').map((x, i) => {
            return Number(x)
        });
        var bbb = []

        var bb = readline().split(' ').map((x, i) => {
            answer.push([aa[i], Number(x)])
            return Number(x)
        })
        var result = 0
        var count = 0
        var ii = 0
        var a1 = 0
        var b1 = 0
        // console.log(aaa)
        // console.log(bbb)
        answer.map((x, i) => {
            a1 = aaa[answer[i][0]] ? aaa[answer[i][0]] : 0
            b1 = bbb[answer[i][1]] ? bbb[answer[i][1]] : 0
            // console.log(i, a1, b1, i+1-a1 - b1)
            count = i-a1 - b1
            aaa[answer[i][0]] = a1 + 1
            bbb[answer[i][1]] = b1 + 1

            result+= count > 0 ? count : 0
        })
        console.log(result)
    })
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var A = nextInt();
		var B = nextInt();
		var K = nextInt();
		var list = new Array(A + B);
		for(var j = 0; j < A + B; j++){
			list[j] = {
				child : new Set()
			};
		}
		var L = nextIntArray(K);
		var R = nextIntArray(K);
		for(var j = 0; j < K; j++){
			list[L[j] - 1].child.add(A + R[j] - 1);
			list[A + R[j] - 1].child.add(L[j] - 1);
		}
		var Edge = K;
		var output = 0;
		for(var j = 0; j < K; j++){
			output += Edge - (list[L[j] - 1].child.size + list[A + R[j] - 1].child.size - 1);
			Edge--;
			list[L[j] - 1].child.delete(A + R[j] - 1);
			list[A + R[j] - 1].child.delete(L[j] - 1);
		}
		myout(output);
	}
}


Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.Sergey gives Nastya the word t and wants to get the word p out of it. Nastya removes letters in a certain order (one after another, in this order strictly), which is specified by permutation of letters' indices of the word t: a1... a|t|. We denote the length of word x as |x|. Note that after removing one letter, the indices of other letters don't change. For example, if t = "nastya" and a = [4, 1, 5, 3, 2, 6] then removals make the following sequence of words "nastya"  "nastya"  "nastya"  "nastya"  "nastya"  "nastya"  "nastya".Sergey knows this permutation. His goal is to stop his sister at some point and continue removing by himself to get the word p. Since Nastya likes this activity, Sergey wants to stop her as late as possible. Your task is to determine, how many letters Nastya can remove before she will be stopped by Sergey.It is guaranteed that the word p can be obtained by removing the letters from word t.

The first and second lines of the input contain the words t and p, respectively. Words are composed of lowercase letters of the Latin alphabet (1 ≤ |p| < |t| ≤ 200 000). It is guaranteed that the word p can be obtained by removing the letters from word t. Next line contains a permutation a1, a2, ..., a|t| of letter indices that specifies the order in which Nastya removes letters of t (1 ≤ ai ≤ |t|, all ai are distinct).

Print a single integer number, the maximum number of letters that Nastya can remove.

NoteIn the first sample test sequence of removing made by Nastya looks like this:"ababcba"  "ababcba"  "ababcba"  "ababcba" Nastya can not continue, because it is impossible to get word "abb" from word "ababcba".So, Nastya will remove only three letters.

var str1 = readline();
var str2 = readline();
var op = readline().split(' ').map(Number);

var len1 = str1.length;
var len2 = str2.length;

var l = 0;
var r = len1;

var flags = [];

var test = function(x) {
  flags = [];
  var c = 0;
  for(var i = 0; i < x; i += 1) {
    flags[op[i] - 1] = true;
  }
  for(var i = 0; i < len1; i += 1) {
    if(!flags[i]) {
      c += (str2[c] === str1[i]) ? 1 : 0;
    }
  }
  return c >= len2;
}

while(l <= r) {
  var m = Math.floor((l + r) / 2);
  if(test(m)) {
    l = m + 1;
  } else {
    r = m - 1;
  }
}

print(l - 1);

Str1 = readline();
Str2 = readline();
Forbid = Array(Str1.length);
Pos = readline().split(' ').map(Number).map(x => x-1);
var l = 0,r = Str1.length;
var mid;
while(l < r) {
	mid = Math.ceil((l+r)/2);
	for(var i = 0;i < Str1.length;i++) {
		Forbid[i] = 0;
	}
	for(var i = 0;i<mid;i++) {
		Forbid[Pos[i]] = 1;
	}
	if(((ju,mStr1,mStr2,mForbid) => {
		//print(mForbid);
		var a=0,b=0;
		while(a < mStr1.length && b < mStr2.length) {
			while(a < mStr1.length && mForbid[a]==1)
				a++;
			if(a == mStr1.length)
				break;
			if(mStr1[a] == mStr2[b])  {
				b++;
				//print(a,b);
			}
			a++;
		}
		if(b==mStr2.length)
			return true;
		return false;
	})(mid,Str1,Str2,Forbid)) {
		l = mid;
	}
	else r = mid-1;
	//print(l,r);
}
print(l);