var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

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

function div(a, b) {
   return Math.floor(a / b);
}

var erat = [];
var pArr = [];
function fillErat() {
   for (var i = 2; i < 100000; i++) {
      if (erat[i]) {
         continue;
      }
      pArr.push(i);
      for (var j = i * 2; j < 100000; j += i) {
         erat[j] = 1;
      }
   }
}
fillErat();

function solve() {
   var abk = readArray(Number);
   var a = abk[0];
   var b = abk[1];
   var canDiv = a % b === 0 || b % a === 0;
   var isEqual = a === b;
   var k = abk[2];
   var maxAns = 0;
   var i = 0;
   while(a !== 1) {
      if (i >= pArr.length) {
         maxAns++;
         break;
      }
      while(a % pArr[i] === 0) {
         maxAns++;
         a = div(a, pArr[i]);
      }
      i++;
   }
   var i = 0;
   while(b !== 1) {
      if (i >= pArr.length) {
         maxAns++;
         break;
      }
      while(b % pArr[i] === 0) {
         maxAns++;
         b = div(b, pArr[i]);
      }
      i++;
   }
   if (k === 1) {
      write(canDiv && !isEqual ? 'YES' : 'NO');
      return;
   }
   if (maxAns < k) {
      write('NO');
      return;
   }
   write('YES');
}

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

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

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

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

   var inTextName;
   var outTextName;

   var needWriteFile = false;

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

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

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

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

function div(a, b) {
   return Math.floor(a / b);
}

var erat = [];
var pArr = [];
function fillErat() {
   for (var i = 2; i <= Math.floor(Math.sqrt(1000000000)); i++) {
      if (erat[i]) {
         continue;
      }
      pArr.push(i);
      for (var j = i * 2; j <= Math.floor(Math.sqrt(1000000000)); j += i) {
         erat[j] = 1;
      }
   }
}
fillErat();

function solve() {
   var abk = readArray(Number);
   var a = abk[0];
   var b = abk[1];
   var canDiv = a % b === 0 || b % a === 0;
   var isEqual = a === b;
   var k = abk[2];
   var maxAns = 0;
   var i = 0;
   while(a !== 1) {
      if (i >= pArr.length) {
         maxAns++;
         break;
      }
      while(a % pArr[i] === 0) {
         maxAns++;
         a = div(a, pArr[i]);
      }
      i++;
   }
   var i = 0;
   while(b !== 1) {
      if (i >= pArr.length) {
         maxAns++;
         break;
      }
      while(b % pArr[i] === 0) {
         maxAns++;
         b = div(b, pArr[i]);
      }
      i++;
   }
   if (k === 1) {
      write(canDiv && !isEqual ? 'YES' : 'NO');
      return;
   }
   if (maxAns < k) {
      write('NO');
      return;
   }
   write('YES');
}

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

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

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

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

   var inTextName;
   var outTextName;

   var needWriteFile = false;

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

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

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

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

function div(a, b) {
   return Math.floor(a / b);
}

var erat = [];
var pArr = [];
function fillErat() {
   for (var i = 2; i < 100000; i++) {
      if (erat[i]) {
         continue;
      }
      pArr.push(i);
      for (var j = i * 2; j < 100000; j += i) {
         erat[j] = 1;
      }
   }
}
fillErat();

function solve() {
   var abk = readArray(Number);
   var a = abk[0];
   var b = abk[1];
   var canDiv = a % b === 0 || b % a === 0;
   var isEqual = a === b;
   var k = abk[2];
   var maxAns = 0;
   var i = 0;
   while(a !== 1) {
      if (i >= pArr.length) {
         maxAns++;
         break;
      }
      while(a % pArr[i] === 0) {
         maxAns++;
         a = div(a, pArr[i]);
      }
      i++;
   }
   var i = 0;
   while(b !== 1) {
      if (i >= pArr.length) {
         maxAns++;
         break;
      }
      while(b % pArr[i] === 0) {
         maxAns++;
         b = div(b, pArr[i]);
      }
      i++;
   }
   if (k === 1) {
      write(canDiv && !isEqual ? 'YES' : 'NO');
      return;
   }
   if (k === 2) {
      write(maxAns >= 2 && maxAns >= 2 ? 'YES' : 'NO');
      return;
   }
   if (maxAns < k) {
      write('NO');
      return;
   }
   write('YES');
}

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

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

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

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

   var inTextName;
   var outTextName;

   var needWriteFile = false;

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

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

'use strict';

const primes = new Set(getPrimes(10 ** 5));
function solve(n, m, k) {
  if (k === 1) return (n % m === 0 || m % n === 0) && n !== m ? 'YES' : 'NO';
  let a = 0,
      b = 0;
  for (let num of primes) {
    if (num > n && num > m) break;
    while (n % num === 0) {
      a++;
      n /= num;
    }
    while (m % num === 0) {
      b++;
      m /= num;
    }
    if (a + b >= k) return 'YES';
  }
  if (n > 1 && !primes.has(n)) a++;
  if (m > 1 && !primes.has(m)) b++;
  if (a + b >= k) return 'YES';
  return 'NO';
}
function getPrimes(n) {
  const nums = new Array(n + 1).fill(1);
  nums[0] = nums[1] = 0;
  const primes = [];
  for (let i = 2; i <= n; i++) {
    if (nums[i]) primes.push(i);
    for (let num of primes) {
      const j = num * i;
      if (j > n) break;
      nums[j] = 0;
      if (i % num === 0) break;
    }
  }
  return primes;
}

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

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        console.log(solve(lines[l++].split(' ').map(Number)));
    }
});

const PRIMES = primes(Math.ceil(Math.sqrt(1e9)))
function primes(n) {
    const flag = Array(n + 1).fill(true)
    flag[0] = false
    flag[1] = false

    const limit = Math.floor(Math.sqrt(n))
    for (let i = 2; i <= limit; i++) {
        for (let j = i * i; j <= n; j += i) {
            flag[j] = false
        }
    }

    const ps = []
    for (let i = 2; i <= n; i++) {
        if (flag[i]) ps.push(i)
    }
    return ps
}
function solve([a, b, k]) {
    return isOK(a, b, k) ? 'YES' : 'NO'
}

function isOK(a, b, k) {
    const g = gcd(a, b)
    const n1 = getFactorCount(a / g)
    const n2 = getFactorCount(b / g)
    const n = getFactorCount(g)

    const divided = a === g || b === g
    if (a === b) {
        const min = 0
        const max = 2 * n
        return k >= min && k <= max && k !== 1
    } else if (divided) {
        const min = 1
        const max = n1 + n2 + 2 * n
        return k >= min && k <= max
    } else {
        const min = 2
        const max = n1 + n2 + 2 * n
        return k >= min && k <= max
    }
}
function getFactorCount(n) {
    if (n < 2) return 0

    let c = 0
    let x = n
    PRIMES.some(p => {
        while (!(x % p)) {
            c++
            x /= p
        }
        if (p >= x) return true
    })
    if (x !== 1) c++ // the last non-divided big prime
    return c
}

function gcd(a, b) {
    if (a === 0) return b
    if (b === 0) return a

    while (a) {
        const r = b % a
        b = a
        a = r
    }
    return b
}

'use strict';
const readline = require('readline');
const util = require('util');
const rl = readline.createInterface({
    input: process.stdin,
});
let pos = 0;
const words = [];
rl.on('line', (line) => {
    words.push.apply(words, line.split(' ').filter(s => s != ''));
});
rl.on('close', main);
function check(b) {
    if (!b) {
        process.stderr.write(`${new Error().stack}\n`);
        process.exit(-1);
    }
}
function printf(...args) {
    process.stdout.write(util.format(...args));
}
function nextInt() {
    return Math.trunc(Number(words[pos++]));
}
function nextStr() {
    return words[pos++];
}
function af(l) {
    return Array.from({ length: l });
}
const INIT = -1;
let a;
let b;
let k;
const MAX = 50000;
let primes = [];
let sieve = new Int32Array(MAX).fill(0);
function precalc() {
    sieve[1] = 1;
    for (let i = 2; i < MAX; i++) {
        if (sieve[i] == 0) {
            sieve[i] = i;
            primes.push(i);
            for (let j = i; i * j < MAX; j++) {
                sieve[i * j] = i;
            }
        }
    }
    //  console.log(primes);
}
function npf(x) {
    let rv = 0;
    for (let p of primes) {
        if (p > x) {
            break;
        }
        while ((x % p) == 0) {
            rv++;
            x /= p;
        }
    }
    if (x > 1) { // x included a large prime
        rv++;
    }
    return rv;
}
function gcd(a, b) {
    while (a > 0) {
        let c = a;
        a = b % a;
        b = c;
    }
    return b;
}
function solve() {
    // printf("npf(%d) %d\n", a, npf(a));
    // printf("npf(%d) %d\n", b, npf(b));
    let g = gcd(a, b);
    if (k == 1) {
        if (a == b) {
            return false;
        }
        return a == g || b == g;
    }
    let mx = npf(a) + npf(b);
    if (k > mx) {
        return false;
    }
    return true;
}
function main() {
    let tc = nextInt();
    precalc();
    check(npf(1000000007) == 1);
    while (tc-- > 0) {
        a = nextInt();
        b = nextInt();
        k = nextInt();
        if (solve()) {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
}

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

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

function div(a, b) {
   return Math.floor(a / b);
}

var erat = [];
var pArr = [];
function fillErat() {
   for (var i = 2; i < 100000; i++) {
      if (erat[i]) {
         continue;
      }
      pArr.push(i);
   }
}
fillErat();

function solve() {
   var abk = readArray(Number);
   var a = abk[0];
   var b = abk[1];
   var canDiv = a % b === 0 || b % a === 0;
   var isEqual = a === b;
   var k = abk[2];
   var parra = [0, 0];
   var parrb = [0, 0];
   var i = 2;
   while(a !== 1) {
      parra[i] = 0;
      while(a % i === 0) {
         parra[i]++;
         a = div(a, i);
      }
      i++;
   }
   var i = 2;
   while(b !== 1) {
      parrb[i] = 0;
      while(b % i === 0) {
         parrb[i]++;
         b = div(b, i);
      }
      i++;
   }
   while (parra.length < parrb.length) {
      parra.push(0);
   }
   while (parrb.length < parra.length) {
      parrb.push(0);
   }
   var maxAns = 0;
   var minAns = 0;
   for (var i = 0; i < parrb.length; i++) {
      minAns += Math.abs(parrb[i] - parra[i]);
      maxAns += parra[i] + parrb[i];
   }
   if (k === 1) {
      write(canDiv && !isEqual ? 'YES' : 'NO');
      return;
   }
   if (k === 2) {
      write(maxAns >= 2 && maxAns >= 2 ? 'YES' : 'NO');
      return;
   }
   if (minAns > k || maxAns < k) {
      write('NO');
      return;
   }
   write('YES');
}

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

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

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

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

   var inTextName;
   var outTextName;

   var needWriteFile = false;

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

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

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

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

function div(a, b) {
   return Math.floor(a / b);
}

var erat = [];
var pArr = [];
function fillErat() {
   for (var i = 2; i < 100000; i++) {
      if (erat[i]) {
         continue;
      }
      pArr.push(i);
   }
}
fillErat();

function solve() {
   var abk = readArray(Number);
   var a = abk[0];
   var b = abk[1];
   var canDiv = a % b === 0 || b % a === 0;
   var isEqual = a === b;
   var k = abk[2];
   var parra = [0, 0];
   var parrb = [0, 0];
   var i = 2;
   while(a !== 1) {
      parra[i] = 0;
      while(a % i === 0) {
         parra[i]++;
         a = div(a, i);
      }
      i++;
   }
   var i = 2;
   while(b !== 1) {
      parrb[i] = 0;
      while(b % i === 0) {
         parrb[i]++;
         b = div(b, i);
      }
      i++;
   }
   while (parra.length < parrb.length) {
      parra.push(0);
   }
   while (parrb.length < parra.length) {
      parrb.push(0);
   }
   var maxAns = 0;
   var minAns = 0;
   for (var i = 0; i < parrb.length; i++) {
      minAns += Math.abs(parrb[i] - parra[i]);
      maxAns += parra[i] + parrb[i];
   }
   if (k === 1) {
      write(canDiv && !isEqual ? 'YES' : 'NO');
      return;
   }
   if (k === 2) {
      write(maxAns >= 2 && maxAns >= 2 ? 'YES' : 'NO');
      return;
   }
   if (minAns > k || maxAns < k) {
      write('NO');
      return;
   }
   if (isEqual) {
      write((k & 1) ? 'NO' : 'YES');
      return;
   }
   write('YES');
}

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

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

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

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

   var inTextName;
   var outTextName;

   var needWriteFile = false;

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

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

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

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

function div(a, b) {
   return Math.floor(a / b);
}

var erat = [];
var pArr = [];
function fillErat() {
   for (var i = 2; i < 100000; i++) {
      if (erat[i]) {
         continue;
      }
      pArr.push(i);
   }
}
fillErat();

function solve() {
   var abk = readArray(Number);
   var a = abk[0];
   var b = abk[1];
   var minAns = a % b === 0 || b % a === 0 ? 1 : 2;
   var isEqual = a === b;
   var k = abk[2];
   var parra = [0, 0];
   var parrb = [0, 0];
   var i = 2;
   while(a !== 1) {
      parra[i] = 0;
      while(a % i === 0) {
         parra[i]++;
         a = div(a, i);
      }
      i++;
   }
   var i = 2;
   while(b !== 1) {
      parrb[i] = 0;
      while(b % i === 0) {
         parrb[i]++;
         b = div(b, i);
      }
      i++;
   }
   while (parra.length < parrb.length) {
      parra.push(0);
   }
   while (parrb.length < parra.length) {
      parrb.push(0);
   }
   var maxAns = 0;
   for (var i = 0; i < parrb.length; i++) {
      maxAns += parra[i] + parrb[i];
   }
   if (minAns > k || maxAns < k) {
      write('NO');
      return;
   }
   if (isEqual) {
      write((k & 1) ? 'NO' : 'YES');
      return;
   }
   write('YES');
}

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

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

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

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

   var inTextName;
   var outTextName;

   var needWriteFile = false;

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

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

'use strict';

const primes = new Set(getPrimes(10 ** 5));
function solve(n, m, k) {
  if (k === 1) return (n % m === 0 || m % n === 0) && n !== m ? 'YES' : 'NO';
  let a = 0,
      b = 0;
  for (let num of primes) {
    if (num > n && num > m) break;
    while (n % num === 0) {
      a++;
      n /= num;
    }
    while (m % num === 0) {
      b++;
      m /= num;
    }
    if (a + b >= k) return 'YES';
  }
  if (n > 1 && !primes.has(n)) a++;
  if (n > 1 && !primes.has(m)) b++;
  if (a + b >= k) return 'YES';
  return 'NO';
}
function getPrimes(n) {
  const nums = new Array(n + 1).fill(1);
  nums[0] = nums[1] = 0;
  const primes = [];
  for (let i = 2; i <= n; i++) {
    if (nums[i]) primes.push(i);
    for (let num of primes) {
      const j = num * i;
      if (j > n) break;
      nums[j] = 0;
      if (i % num === 0) break;
    }
  }
  return primes;
}

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

'use strict';

const primes = new Set(getPrimes(10 ** 5));
function solve(n, m, k) {
  if (k > 1000) return 'NO';
  if (k === 1) return (n % m === 0 || m % n === 0) && n !== m ? 'YES' : 'NO';
  let a = 0,
      b = 0;
  for (let num of primes) {
    while (n % num === 0) {
      a++;
      n /= num;
    }
    while (m % num === 0) {
      b++;
      m /= num;
    }
    if (a + b >= k) return 'YES';
  }
  if (!primes.has(n)) a++;
  if (!primes.has(m)) b++;
  if (a + b >= k) return 'YES';
  return 'NO';
}
function getPrimes(n) {
  const nums = new Array(n + 1).fill(1);
  nums[0] = nums[1] = 0;
  const primes = [];
  for (let i = 2; i <= n; i++) {
    if (nums[i]) primes.push(i);
    for (let num of primes) {
      const j = num * i;
      if (j > n) break;
      nums[j] = 0;
      if (i % num === 0) break;
    }
  }
  return primes;
}

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

'use strict';

function solve(n, m, k) {
  if (n === m && k & 1) return 'NO';
  if (k === 1) return (n % m === 0 || m % n === 0) && n !== m ? 'YES' : 'NO';
  const count = n => {
    if (n === 2) return 1;
    let res = 0;
    for (let i = 2; i <= n; i++) {
      while (n % i === 0) {
        res++;
        n /= i;
      }
    }
    return res;
  };
  let max = count(n) + count(m);
  if (k > max) return 'NO';
  return 'YES';
}

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

'use strict';

function solve(n, m, k) {
  if (n === m && k & 1) return 'NO';
  if (k === 1) return (n % m === 0 || m % n === 0) && n !== m ? 'YES' : 'NO';
  const count = n => {
    if (n === 2) return 1;
    let res = 0;
    for (let i = 2; i <= n / i; i++) {
      while (n % i === 0) {
        res++;
        n /= i;
      }
    }
    return res;
  };
  let max = count(n) + count(m);
  if (k > max) return 'NO';
  return 'YES';
}

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

'use strict';

function solve(n, m, k) {
  if (k === 1) return (n % m === 0 || m % n === 0) && n !== m ? 'YES' : 'NO';
  const count = n => {
    if (n === 2) return 1;
    let res = 0;
    for (let i = 2; i <= n / i; i++) {
      while (n % i === 0) {
        res++;
        n /= i;
      }
    }
    return res;
  };
  let max = count(n) + count(m);
  return k <= max ? 'YES' : 'NO';
}

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

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        console.log(solve(lines[l++].split(' ').map(Number)));
    }
});

const PRIMES = primes(Math.ceil(Math.sqrt(1e9)))
function primes(n) {
    const flag = Array(n + 1).fill(true)
    flag[0] = false
    flag[1] = false

    const limit = Math.floor(Math.sqrt(n))
    for (let i = 2; i <= limit; i++) {
        for (let j = i * i; j <= n; j += i) {
            flag[j] = false
        }
    }

    const ps = []
    for (let i = 2; i <= n; i++) {
        if (flag[i]) ps.push(i)
    }
    return ps
}
function solve([a, b, k]) {
    return isOK(a, b, k) ? 'YES' : 'NO'
}

function isOK(a, b, k) {
    const g = gcd(a, b)
    const n1 = getFactorCount(a / g)
    const n2 = getFactorCount(b / g)
    const n = getFactorCount(g)
    console.log(a, b, g, '-', n1, n2, n)

    const divided = a === g || b === g
    if (a === b) {
        const min = 0
        const max = 2 * n
        return k >= min && k <= max && k !== 1
    } else if (divided) {
        const min = 1
        const max = n1 + n2 + 2 * n
        return k >= min && k <= max
    } else {
        const min = 2
        const max = n1 + n2 + 2 * n
        return k >= min && k <= max
    }
}
function getFactorCount(n) {
    if (n < 2) return 0

    let c = 0
    let x = n
    PRIMES.some(p => {
        while (!(x % p)) {
            c++
            x /= p
        }
        if (p >= x) return true
    })
    if (x !== 1) c++ // the last non-divided big prime
    return c
}

function gcd(a, b) {
    if (a === 0) return b
    if (b === 0) return a

    while (a) {
        const r = b % a
        b = a
        a = r
    }
    return b
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        console.log(solve(lines[l++].split(' ').map(Number)));
    }
});

const PRIMES = primes(Math.ceil(Math.sqrt(1e9)))
function primes(n) {
    const flag = Array(n + 1).fill(true)
    flag[0] = false
    flag[1] = false

    const limit = Math.floor(Math.sqrt(n))
    for (let i = 2; i <= limit; i++) {
        for (let j = i * i; j <= n; j += i) {
            flag[j] = false
        }
    }

    const ps = []
    for (let i = 2; i <= n; i++) {
        if (flag[i]) ps.push(i)
    }
    return ps
}
function solve([a, b, k]) {
    return isOK(a, b, k) ? 'YES' : 'NO'
}

function isOK(a, b, k) {
    const g = gcd(a, b)
    const n1 = getFactorCount(a / g)
    const n2 = getFactorCount(b / g)
    const n = getFactorCount(g)

    const divided = a === g || b === g
    if (a === b) {
        const min = 0
        const max = 2 * n
        return k >= min && k <= max && k !== 1
    } else if (divided) {
        const min = 1
        const max = n1 + n2 + 2 * n
        return k >= min && k <= max
    } else {
        const min = 2
        const max = n1 + n2 + 2 * n
        return k >= min && k <= max
    }
}
function getFactorCount(n) {
    if (n < 2) return 0

    let c = 0
    let x = n
    PRIMES.some(p => {
        while (!(x % p)) {
            c++
            x /= p
        }
        if (p >= x) return true
    })
    if (c !== 1) c++ // the last non-divided big prime
    return c
}

function gcd(a, b) {
    if (a === 0) return b
    if (b === 0) return a

    while (a) {
        const r = b % a
        b = a
        a = r
    }
    return b
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        console.log(solve(lines[l++].split(' ').map(Number)));
    }
});

const PRIMES = primes(1e5)
function primes(n) {
    const flag = Array(n + 1).fill(true)
    flag[0] = false
    flag[1] = false

    const limit = Math.floor(Math.sqrt(n))
    for (let i = 2; i <= limit; i++) {
        if (!flag[i]) continue
        for (let j = i * 2; j <= n; j += i) {
            flag[j] = false
        }
    }

    const ps = []
    for (let i = 2; i <= n; i++) {
        if (flag[i]) ps.push(i)
    }
    return ps
}
function solve([a, b, k]) {
    return isOK(a, b, k) ? 'YES' : 'NO'
}

function isOK(a, b, k) {
    const g = gcd(a, b)
    const n1 = getFactorCount(a / g)
    const n2 = getFactorCount(b / g)
    const n = getFactorCount(g)

    const divided = a === g || b === g
    if (a === b) {
        const min = 0
        const max = 2 * n
        return k >= min && k <= max && k !== 1
    } else if (divided) {
        const min = 1
        const max = n1 + n2 + 2 * n
        return k >= min && k <= max
    } else {
        const min = 2
        const max = n1 + n2 + 2 * n
        return k >= min && k <= max
    }
}
function getFactorCount(n) {
    if (n < 2) return 0

    let c = 0
    let x = n
    PRIMES.some(p => {
        while (!(x % p)) {
            c++
            x /= p
        }
        if (p >= x) return true
    })
    return c
}

function gcd(a, b) {
    if (a === 0) return b
    if (b === 0) return a

    while (a) {
        const r = b % a
        b = a
        a = r
    }
    return b
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        console.log(solve(lines[l++].split(' ').map(Number)));
    }
});

const PRIMES = primes(1e5)
function primes(n) {
    const flag = Array(n + 1).fill(true)
    flag[0] = false
    flag[1] = false

    const limit = Math.floor(Math.sqrt(n))
    for (let i = 2; i <= limit; i++) {
        if (!flag[i]) continue
        for (let j = i * 2; j <= n; j += i) {
            flag[j] = false
        }
    }

    const ps = []
    for (let i = 2; i <= n; i++) {
        if (flag[i]) ps.push(i)
    }
    return ps
}
function solve([a, b, k]) {
    return isOK(a, b, k) ? 'YES' : 'NO'
}

function isOK(a, b, k) {
    const g = gcd(a, b)
    const n1 = getFactorCount(a / g)
    const n2 = getFactorCount(b / g)
    const n = getFactorCount(g)

    const divided = a === g || b === g
    if (k <= n1 + n2) {
        if (divided) {
            // [1, n1 + n2]
            return k >= 1
        } else {
            // [2, n1 + n2]
            return k >= 2
        }
    }

    k -= (n1 + n2) // greedy
    if (k & 1) {
        const k2 = n1 + n2 - 1
        if (divided && k2 < 1 || k2 < 2) return false
        k++
    }
    return !(k & 1) && k <= 2 * n
}
function getFactorCount(n) {
    if (n < 2) return 0

    let c = 0
    let x = n
    PRIMES.some(p => {
        while (!(x % p)) {
            c++
            x /= p
        }
        if (p >= x) return true
    })
    return c
}

function gcd(a, b) {
    if (a === 0) return b
    if (b === 0) return a

    while (a) {
        const r = b % a
        b = a
        a = r
    }
    return b
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        console.log(solve(lines[l++].split(' ').map(Number)));
    }
});

const PRIMES = primes(1e7)
function primes(n) {
    const flag = Array(n + 1).fill(true)
    flag[0] = false
    flag[1] = false

    const limit = Math.floor(Math.sqrt(n))
    for (let i = 2; i <= limit; i++) {
        if (!flag[i]) continue
        for (let j = i * 2; j <= n; j += i) {
            flag[j] = false
        }
    }

    const ps = []
    for (let i = 2; i <= n; i++) {
        if (flag[i]) ps.push(i)
    }
    return ps
}
function solve([a, b, k]) {
    return isOK(a, b, k) ? 'YES' : 'NO'
}

function isOK(a, b, k) {
    if (a === b) {
        const n = getFactorCount(a)
        return !(k & 1) && n >= 2 * k
    }

    const g = gcd(a, b)
    if (g === 1) {
        if (a === 1 || b === 1) return k === 1
        return k === 2
    } else {
        const n1 = getFactorCount(a / g)
        const n2 = getFactorCount(b / g)
        const n = getFactorCount(g)
        if (a === g || b === g) {
            return k <= n1 + n2 + n
        }
        return k >= 2 && k <= n1 + n2 + n
    }
}
function getFactorCount(n) {
    if (n < 2) return 0

    let c = 0
    let x = n
    PRIMES.some(p => {
        while (!(x % p)) {
            c++
            x /= p
        }
        if (p >= x) return true
    })
    return c
}

function gcd(a, b) {
    if (a === 0) return b
    if (b === 0) return a

    while (a) {
        const r = b % a
        b = a
        a = r
    }
    return b
}

'use strict';
const readline = require('readline');
const util = require('util');
const rl = readline.createInterface({
    input: process.stdin,
});
let pos = 0;
const words = [];
rl.on('line', (line) => {
    words.push.apply(words, line.split(' ').filter(s => s != ''));
});
rl.on('close', main);
function check(b) {
    if (!b) {
        process.stderr.write(`${new Error().stack}\n`);
        process.exit(-1);
    }
}
function printf(...args) {
    process.stdout.write(util.format(...args));
}
function nextInt() {
    return Math.trunc(Number(words[pos++]));
}
function nextStr() {
    return words[pos++];
}
function af(l) {
    return Array.from({ length: l });
}
const INIT = -1;
let a;
let b;
let k;
const MAX = 50000;
let primes = [];
let sieve = new Int32Array(MAX).fill(0);
function precalc() {
    sieve[1] = 1;
    for (let i = 2; i < MAX; i++) {
        if (sieve[i] == 0) {
            sieve[i] = i;
            primes.push(i);
            for (let j = i; i * j < MAX; j++) {
                sieve[i * j] = i;
            }
        }
    }
    //  console.log(primes);
}
function npf(x) {
    let rv = 0;
    for (let p of primes) {
        if (p > x) {
            break;
        }
        while ((x % p) == 0) {
            rv++;
            x /= p;
        }
    }
    if (x > 1) { // x was a large prime
        return 1;
    }
    return rv;
}
function gcd(a, b) {
    while (a > 0) {
        let c = a;
        a = b % a;
        b = c;
    }
    return b;
}
function solve() {
    // printf("npf(%d) %d\n", a, npf(a));
    // printf("npf(%d) %d\n", b, npf(b));
    let g = gcd(a, b);
    if (k == 1) {
        if (a == b) {
            return false;
        }
        return a == g || b == g;
    }
    let mx = npf(a) + npf(b);
    if (k > mx) {
        return false;
    }
    return true;
}
function main() {
    let tc = nextInt();
    precalc();
    check(npf(1000000007) == 1);
    while (tc-- > 0) {
        a = nextInt();
        b = nextInt();
        k = nextInt();
        if (solve()) {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
}

'use strict';
const readline = require('readline');
const util = require('util');
const rl = readline.createInterface({
    input: process.stdin,
});
let pos = 0;
const words = [];
rl.on('line', (line) => {
    words.push.apply(words, line.split(' ').filter(s => s != ''));
});
rl.on('close', main);
function check(b) {
    if (!b) {
        process.stderr.write(`${new Error().stack}\n`);
        process.exit(-1);
    }
}
function printf(...args) {
    process.stdout.write(util.format(...args));
}
function nextInt() {
    return Math.trunc(Number(words[pos++]));
}
function nextStr() {
    return words[pos++];
}
function af(l) {
    return Array.from({ length: l });
}
const INIT = -1;
let a;
let b;
let k;
const MAX = 50000;
let primes = [];
let sieve = new Int32Array(MAX).fill(0);
function precalc() {
    sieve[1] = 1;
    for (let i = 2; i < MAX; i++) {
        if (sieve[i] == 0) {
            sieve[i] = i;
            primes.push(i);
            for (let j = i; i * j < MAX; j++) {
                sieve[i * j] = i;
            }
        }
    }
    //  console.log(primes);
}
function npf(x) {
    let rv = 0;
    for (let p of primes) {
        if (p > x) {
            break;
        }
        while ((x % p) == 0) {
            rv++;
            x /= p;
        }
    }
    if (x > 1) { // x was a large prime
        return 1;
    }
    return rv;
}
function gcd(a, b) {
    while (a > 0) {
        let c = a;
        a = b % a;
        b = c;
    }
    return b;
}
function solve() {
    // printf("npf(%d) %d\n", a, npf(a));
    // printf("npf(%d) %d\n", b, npf(b));
    let g = gcd(a, b);
    if (k == 1) {
        if (a == b) {
            return false;
        }
        return a == g || b == g;
    }
    let mx = npf(a) + npf(b);
    if (k > mx) {
        return false;
    }
    if ((k % 2) == 1) {
        a /= g;
        b /= g;
        return npf(a) != npf(b);
    }
    return true;
}
function main() {
    let tc = nextInt();
    precalc();
    check(npf(1000000007) == 1);
    while (tc-- > 0) {
        a = nextInt();
        b = nextInt();
        k = nextInt();
        if (solve()) {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
}


const readline = require('readline');
const input = [];
function A(q) {
    for (let i = 1; i <= Number(q[0]); i++) {
        console.log(solve(q[i]))
    }
}
function solve(n) {
    const ang1 = Math.PI / n;
    const R = 0.5 / Math.sin(ang1 / 2);
    const shift = Math.PI / (2*n);
    let xl = Number.MAX_VALUE;
    let yb = Number.MAX_VALUE;
    let xr = Number.MIN_VALUE;
    let yt = Number.MIN_VALUE;
    for (let i = 0; i < n; i++) {
        const x = Math.cos(Math.PI / n * i + shift);
        const y = Math.sin(Math.PI / n * i + shift);
        xl = Math.min(xl, x);
        xr = Math.max(xr, x);
        yb = Math.min(yb, y);
        yt = Math.max(yt, y);
    }
    const side = Math.max(xr - xl, yt - yb) * R;
    return side.toPrecision(10);
}
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
rl.on('line', q => {
    input.push(q.trim())
});
rl.on('close', () => {
    A(input);
})

function Main() {
  var A = Number(readline());
  for(var i=0;i<A;i++){
    var r = 1/(2*Math.sin(Math.PI/(2*Number(readline()))));
    var t = Math.sqrt(r*r - 0.25);
    print(t*2);
  }
}
Main();


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(2 * t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var list = nextCharArray();
    var out = new Array(N);
    out[0] = 1;
    var lastOne = [];
    var lastZero = [];
    if(list[0] == "1"){
      lastOne.push(1);
    }else{
      lastZero.push(1);
    }
    for(var j = 1; j < N; j++){
      if(list[j] == "1"){
        if(lastZero.length != 0){
          var tmplist = lastZero.pop();
          lastOne.push(tmplist);
          out[j] = tmplist;
        }else{
          lastOne.push(lastOne.length + 1);
          out[j] = lastOne.length;
        }
      }else{
        if(lastOne.length != 0){
          var tmplist = lastOne.pop();
          lastZero.push(tmplist);
          out[j] = tmplist;
        }else{
          lastZero.push(lastZero.length + 1);
          out[j] = lastZero.length;
        }
      }
    }
    output[i * 2] = lastOne.length + lastZero.length;
    output[i * 2 + 1] = myconv(out, 8);
  }
  myout(myconv(output, 9));
}

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

    for (let i = 0; i < len; i++) {
      const char = str[i];
      const patternCount = patternEndsWith0.length + patternEndsWith1.length + 1;
      if (char === "0") {
        if (patternEndsWith1.length > 0) {
          const pattern = patternEndsWith1.pop();
          patternEndsWith0.push(pattern);
          result.push(pattern);
        } else {
          patternEndsWith0.push(patternCount);
          result.push(patternCount);
        }
      } else {
        if (char === "1") {
          if (patternEndsWith0.length > 0) {
            const pattern = patternEndsWith0.pop();
            patternEndsWith1.push(pattern);
            result.push(pattern);
          } else {
            patternEndsWith1.push(patternCount);
            result.push(patternCount);
          }
        }
      }
    }
    console.log(patternEndsWith0.length + patternEndsWith1.length);
    console.log(result.join(" "));
  }
}

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

    main()
})

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

const s2i = s => parseInt(s, 10)

const readLineOfBigInts = () => {
  const split = readLine().split(' ')
  const result = []
  for (let i = 0, l = split.length; i < l; i++) {
    result.push(BigInt(split[i]));
  }
  return result
}

function main() {
  let T = s2i(readLine())
  let out = ''

  while (T--) {
    const n = s2i(readLine())
    const s = readLine()

    let c0 = []
    let c1 = []
    let next = 1
    let moves = []

    for (let i = 0, seq, from, to; i < n; i++) {
      if (s.charAt(i) === '0') {
        from = c1
        to = c0
      } else {
        from = c0
        to = c1
      }

      if (from.length) {
        seq = from.pop()
      } else {
        seq = next++
      }
      to.push(seq)

      moves.push(seq)
    }

    out += (c0.length + c1.length) + '\n'
    out += moves.join(' ') + '\n'
  }

  console.log(out)
}

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 t = parseInt(readline());
    for(let k = 0; k < t; k++){
        let n = parseInt(readline());
        if(n === 0){
            console.log(0);
            console.log();
            continue;
        }
        let arr = readline().split('');
        let res = new Array(arr.length);
        let hMap = {'0': [], '1': []};
        let count = 0;
        for(let i = 0; i < arr.length; i++){
            if(arr[i] === '0'){
                if(hMap['0'].length > 0){
                    let index = hMap['0'].pop();
                    res[i] = index;
                    hMap['1'].push(index);
                }
                else{
                    hMap['1'].push(++count);
                    res[i] = count;
                }
            }else{
                if(hMap['1'].length > 0){
                    let index = hMap['1'].pop();
                    res[i] = index;
                    hMap['0'].push(index);
                }else{
                    hMap['0'].push(++count);
                    res[i] = count;
                }
            }
        }
        console.log(count);
        for(num of res)
            console.log(num);
    }
}

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

    for (let i = 0; i < len; i++) {
      const char = str[i];
      const patternCount = patternEndsWith0.length + patternEndsWith1.length + 1;
      if (char === "0") {
        if (patternEndsWith1.length > 0) {
          const pattern = patternEndsWith1.pop();
          patternEndsWith0.push(pattern);
          result.push(pattern);
        } else {
          patternEndsWith0.push(patternCount);
          result.push(patternCount);
        }
      } else {
        if (char === "1") {
          if (patternEndsWith0.length > 0) {
            const pattern = patternEndsWith0.pop();
            patternEndsWith1.push(pattern);
            result.push(pattern);
          } else {
            patternEndsWith1.push(patternCount);
            result.push(patternCount);
          }
        }
      }
    }
    console.log(result.join(" "));
  }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(2 * t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var list = nextCharArray();
    var map = {
      1 : list[0]
    };
    var out = new Array(N);
    out[0] = 1;
    var lastOne = new Set();
    var lastZero = new Set();
    if(list[0] == "1"){
      lastOne.add(1);
    }else{
      lastZero.add(1);
    }
    for(var j = 1; j < N; j++){
      var keys = Object.keys(map);
      var isOK = false;
      if(list[j] == "1"){
        if(lastZero.size != 0){
          var tmplist = Array.from(lastZero);
          lastZero.delete(tmplist[0]);
          lastOne.add(tmplist[0]);
          out[j] = tmplist[0];
        }else{
          lastOne.add(lastOne.size + 1);
          out[j] = lastOne.size;
        }
      }else{
        if(lastOne.size != 0){
          var tmplist = Array.from(lastOne);
          lastOne.delete(tmplist[0]);
          lastZero.add(tmplist[0]);
          out[j] = tmplist[0];
        }else{
          lastZero.add(lastZero.size + 1);
          out[j] = lastZero.size;
        }
      }
    }
    output[i * 2] = Object.keys(map).length;
    output[i * 2 + 1] = myconv(out, 8);
  }
  myout(myconv(output, 9));
}

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 t = parseInt(readline());
    for(let k = 0; k < t; k++){
        let n = parseInt(readline());
        if(n === 0){
            console.log(0);
            console.log([]);
            continue;
        }
        let arr = readline().split('');
        let res = new Array(arr.length);
        let hMap = {'0': [], '1': []};
        let count = 0;
        for(let i = 0; i < arr.length; i++){
            if(arr[i] === '0'){
                if(hMap['0'].length > 0){
                    let index = hMap['0'].pop();
                    res[i] = index;
                    hMap['1'].push(index);
                }
                else{
                    hMap['1'].push(++count);
                    res[i] = count;
                }
            }else{
                if(hMap['1'].length > 0){
                    let index = hMap['1'].pop();
                    res[i] = index;
                    hMap['0'].push(index);
                }else{
                    hMap['0'].push(++count);
                    res[i] = count;
                }
            }
        }
        console.log(count);
        console.log(res);
    }
}

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 t = parseInt(readline());
    for(let k = 0; k < t; k++){
        let n = parseInt(readline());
        let arr = readline().split('');
        let res = new Array(arr.length);
        let hMap = {'0': [], '1': []};
        let count = 0;
        for(let i = 0; i < arr.length; i++){
            if(arr[i] === '0'){
                if(hMap['0'].length > 0){
                    let index = hMap['0'].pop();
                    res[i] = index;
                    hMap['1'].push(index);
                }
                else{
                    hMap['1'].push(++count);
                    res[i] = count;
                }
            }else{
                if(hMap['1'].length > 0){
                    let index = hMap['1'].pop();
                    res[i] = index;
                    hMap['0'].push(index);
                }else{
                    hMap['0'].push(++count);
                    res[i] = count;
                }
            }
        }
        console.log(count);
        console.log(res);
    }
}


"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let min = arr[0],
      ans = 0;
    for (let i = 1; i < n; i++) {
      if (arr[i] < 2 * min) continue;
      else {
          if(arr[i]%((2*min)-1)===0) ans+=arr[i]/((2*min)-1) - 1;
        else ans += Math.floor(arr[i] / ((2*min)-1));
      }
    }
    console.log(ans);
  }
};
solve();

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var a = lines[i].split(' ').map(Number);
            var b = a.sort(function(a, b){return a - b});
            var ans = 0;
            for(j = 1; j < n; j++){
                ans += Math.floor((a[j] - 1) / (b[0] * 2 - 1));
            }
            console.log(ans);
        }
    }
});

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

var input = '';
process.stdin.on('data', function(chunk) {
    input += chunk;
});

function solve(problem) {
    problem.sort((a, b) => b - a);

    const start = problem.pop();
    const divider = start * 2 - 1;

    let actions = 0;
    while (problem.length > 0) {
        const current = problem.pop();
        actions += Math.ceil(current / divider) - 1;
    }

    return actions;
}

process.stdin.on('end', function() {
    const data = input.trim().split('\n');

    for (let i = 1; i < data.length; i += 2) {
        const problem = data[i + 1].trim().split(' ').map(Number);

        console.log(solve(problem));
    }
});

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        const n = +readLine();
        const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(n, arr);
        console.log(result);
    }
}

function myFunc(n, arr){
    arr.sort((a, b) => a - b);
    let cont = 0;
    const ref = (arr[0]*2)-1;
    for(let i = 1; i < n; i++){
        // cont += parseInt(arr[i] / ref);
        cont += Math.ceil(arr[i] / ref)-1;
    }

    return cont;
}

'use strict';

var fs = require('fs');

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

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        a = rns(n);
  const min = Math.min(...a) * 2 - 1;
  let res = 0;
  for (let i = 0; i < n; i++) {
    res += Math.ceil(a[i] / min) - 1;
  }
  return res;
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn();
    return res;
  };
  const re = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn() - 1;
    return res;
  };
  const rbs = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rb();
    return res;
  };
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  const [rn, rb, rns, re, rbs] = convertInput(r);
  try {
    let t = rn();
    let res = new Array(t);
    let limit = 100;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8')
.split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

var n = +readline();
for (var i = 0; i < n; i++) {
  var k = +readline();
  var arr = readline().split(' ').map(item => +item);
  var tab = arr[0] * 2 - 1;
  var count = 0;
  for (var j = 0; j < arr.length; j++) {
    count += Math.ceil(arr[j] / tab) - 1;
  }
  print(count);
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let min = arr[0],
      ans = 0;
   if (min === 1) {
      for (let i = 1; i < n; i++) ans += arr[i] - 1;
      console.log(ans);
      continue;
   }
    for (let i = 1; i < n; i++) {
      if (arr[i] < 2 * min) continue;
      else {
        ans += Math.floor(arr[i] / ((2*min)-1));
      }
    }
    console.log(ans);
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let min = arr[0],
      ans = 0;
    if (min === 1) {
      for (let i = 1; i < n; i++) ans += arr[i] - 1;
      console.log(ans);
      continue;
    }
    for (let i = 1; i < n; i++) {
      if (arr[i] <= 2 * min) continue;
      else {
        ans += Math.ceil(arr[i] / (2 * min)) - 1;
      }
    }
    console.log(ans);
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let min = arr[0],
      ans = 0;
    if (min === 1) {
      for (let i = 1; i < n; i++) ans += arr[i] - 1;
      console.log(ans);
      continue;
    }
    for (let i = 1; i < n; i++) {
      if (arr[i] <= 2 * min) continue;
      else {
        ans += Math.floor(arr[i] / (2 * min));
      }
    }
    console.log(ans);
  }
};
solve();

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0, k = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var b = a[0] * 2;
            var e = 0;
            for(j = 1; j < n; j++){
                if(b / 2 == 1){
                    e += a[j] - 1;
                    continue;
                }
                while(a[j] >= b){
                    a[j] /= 2;
                    e++;
                }
            }
            console.log(e);
        }
    }
});

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0, k = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var b = a[0] * 2;
            var e = 0;
            for(j = 1; j < n; j++){
                if(b / 2 == 1){
                    e += a[j] - 1;
                    continue;
                }
                while(a[j] > b){
                    a[j] /= 2;
                    e++;
                }
            }
            console.log(e);
        }
    }
});

var n = +readline();
for (var i = 0; i < n; i++) {
  var k = +readline();
  var arr = readline().split(' ').map(item => +item);
  var tab = Math.min(...arr) * 2 - 1;
  var count = 0;
  for (var j = 0; j < arr.length; j++) {
    count += Math.floor(arr[j] / tab);
  }
  print(tab === 1 ? count - k : count);
}


T = readline()
while (T--) {
   x = readline().split('').map(x => +x)
   min = Math.min(...x)
   if(x.indexOf(min) === 0 && x.length === 2){
      x.shift()
      min = Math.min(...x)
   }
   print(min)
}

const solve = rows => {
    for (let i = 0; i < rows.length; i++) {
        if (rows[i].length < 3) {
            console.log(rows[i][1]);
        } else {
            const nums = rows[i].split('');
            nums.sort((a, b) => a - b);
            console.log(nums[0]);
        }
    }
}
const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

let num = -1;
const rows = [];
rl.on('line', line => {
    if (num < 0) {
        num = parseInt(line.trim());
    } else {
        rows.push(line.trim());
        if (rows.length === num) {
            dealInput();
        }
    }
});
const dealInput = () => {
    solve(rows);
    rl.close();
};

rl.on('close', () => {
    process.exit(0);
});

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;
}
var T = readline();
for(var qe=1;qe<=T;qe++) {
  var n = readline()//.split(' ').map((x) => parseInt(x));
  //n = parseInt(n);
  //var a = readline().split(' ').map((x) => parseInt(x));
  var as = ''+n;
  var len = as.length;
  var a = as.split('');
  var t = [...a]
  var ans = 0;
  t.sort();
  if(len > 2) ans = t[0]
  else if(t[0] != a[0]) ans = t[0]
  else ans = t[1];

  console.log(ans);
  //fs.appendFileSync('output.txt', ans+'\r\n');

}
//

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

    for (let test = 0; test < N; test++) {
        let n = readline();
        let ints = n.split('').map(Number);
        if (ints.length === 1) {
            output(ints[0]);
            continue;
        } else if (ints.length === 2) {
            output(ints[1]);
            continue;
        }
        ints.sort();
        output(ints[0]);
    }
}

const solve = n=>{
     if(n.length===2) return n[1];
     n.sort((a,b)=>a-b);
     return n[0];
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for (let i = 0; i < t; i++) {
       let n = readline().trim().split("").map(cur=>parseInt(cur));
       console.log(solve(n));
  }
}
main();

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

let lines = 0;

rl.on("line", function (line) {
  if (lines !== 0) {
    let input = line.split("").map(Number);
    if (input.length == 2) {
      console.log(input[1]);
    } else {
      console.log(Math.min(...input));
    }
  }

  lines++;
});

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

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

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

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

const calc = ()=>{
    /* read */
    let s = readline().split('').map(a=>+a);

    if (s.length === 2) {
        return s[1];
    }
    let min = s[0];

    for (let i = 1; i < s.length; i++) {
        min = Math.min(min, s[i]);
    }

    return min;

};

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

'use strict';

var readline = require('readline');

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

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

function solve(n) {
  const a = n.toString(10).split('').map(Number);
  if (a.length === 2) return a[1];
  return a.sort((a, b) => a - b)[0];
}

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

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

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

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

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

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

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

// SOLUTION:
IS_MULTITEST = true;

const calc = (testN)=>{
  // READING:
  let s = readline();
  LT({s});
  // PROCESSING:
  let ans = 0;
  if (s.length==2)
    return s[1]
  let min = s[0];
  for (let i=0; i<s.length; i++)
    min = Math.min(min, +s[i])

  return min;
};

function solve(n) {
    const arr = n.split('');
    if (arr.length === 2) {
        return n[1];
    }
    return arr.sort((a, b) => a - b)[0];
}

let text = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', t => {
    if (t === '\r\n' || t === '\n') {
        process.stdin.emit('end');
    } else {
        text += t;
    }
});
process.stdin.on('end', () => {
    const input = text.trim().replace(/\r/g, '').split('\n');
    const dataArr = input.slice(1);

    for (const item of dataArr) {
        console.log(solve(item));
    }
    process.exit();
});

const solve = num => {
    num.trim();
    if (num.length === 2) {
        console.log(Number(num[1]));
    } else {
        const arr = num.split('').map(item => parseInt(item, 10));
        arr.sort((a, b) => a - b);
        console.log(arr[0]);
    }
}

let line = '';
process.stdin.on('data', c => line += c);
process.stdin.on('end', () => {
    const input = line.trim().split('\n');
    const n = parseInt(input[0]);
    for (let i = 1; i <= n; i++) {
        const arr = input[i];
        solve(arr);
    }
});

const solve = arr => {
    if (arr.length === 2) {
        console.log(arr[1]);
    } else {
        arr.sort((a, b) => a - b);
        console.log(arr[0]);
    }
}

let line = '';
process.stdin.on('data', c => line += c);
process.stdin.on('end', () => {
    const input = line.trim().split('\n');
    const n = parseInt(input[0]);
    for (let i = 1; i <= n; i++) {
        const arr = input[i].split('').map(item => parseInt(item));
        solve(arr);
    }
});

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;
}
var T = readline();
for(var qe=1;qe<=T;qe++) {
  var n = readline()//.split(' ').map((x) => parseInt(x));
  //n = parseInt(n);
  //var a = readline().split(' ').map((x) => parseInt(x));
  var as = ''+n;
  var len = as.length;
  var a = as.split('');
  var ans = 0;
  a.sort();
  if(len > 2) ans = a[0]
  else ans = a[1]

  console.log(ans);
  //fs.appendFileSync('output.txt', ans+'\r\n');

}
//


var inp = readline();

// ��������� ������

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }
}
pgs[ parseInt(buff) ] = 1;

// ��������� ���������

var flag = 0, k=0; // �� ���� ����� � res
n = pgs.length;

for(i=0;i<n;i++)
{
  if( pgs[i] == 1 && flag == 0)
  {
    res = res + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] == 1 && flag == 1)
  {
    res = res + "-";
    flag = 2; // �.���� ���� � res
  }
  else if(pgs[i] == 1 && flag == 3)
  {
    res = res + "," + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] != 1 && flag == 1)
  {
    flag = 3; // �.��� ������� ����� � res
  }
  else if(pgs[i] != 1 && flag == 2)
  {
    k = i-1;
    res = res + k.toString(10);
    flag = 3; // �.��� ������� ����� � res
  }
}
if(flag == 2)
{
  k = i-1;
  res = res + k.toString(10);
  flag = 3; // �.��� ������� ����� � res
}

print(res);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var pages = tokenizeIntegers(readline().replace(/,/g, " "));
	var maxPage = 1000;
	var mark = new Array(maxPage+1);
	for (var i = 0; i < pages.length; ++i) {
		mark[pages[i]] = true;
	}

	var spans = [];
	for (var i = 1; i <= maxPage; ++i) {
		if (mark[i]) {
			var start = i;
			while (i < maxPage && mark[i+1]) {
				++i;
			}
			spans.push(i == start ? i : [start, i].join("-"));
		}
	}
	print(spans.join(","));
}

main();

var inp = readline();

// ��������� ������

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }
}

// ��������� ���������

var flag = 0;
n = pgs.length;

for(i=0;i<n;i++)
{
  if( pgs[i] == 1 && flag == 0)
  {
    res = res + i.toString(10);
    flag = 1;
  }
  else if(pgs[i] == 1 && flag == 1)
  {
    res = res + "-";
  }
}

print(res);

/*
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
*/

var inp = readline();

// ��������� ������

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }
}

// ��������� ���������

var flag = 0, k=0; // �� ���� ����� � res
n = pgs.length;

for(i=0;i<n;i++)
{
  if( pgs[i] == 1 && flag == 0)
  {
    res = res + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] == 1 && flag == 1)
  {
    res = res + "-";
    flag = 2; // �.���� ���� � res
  }
  else if(pgs[i] == 1 && flag == 3)
  {
    res = res + "," + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] == 0 && flag == 1)
  {
    flag = 3; // �.��� ������� ����� � res
  }
  else if(pgs[i] == 0 && flag == 2)
  {
    k = i-1;
    res = res + k.toString(10);
    flag = 3; // �.��� ������� ����� � res
  }
}

print(res);

var inp = readline();

// ��������� ������

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }
}

// ��������� ���������

var flag = 0; // �� ���� ����� � res
n = pgs.length;

for(i=0;i<n;i++)
{
  if( pgs[i] == 1 && flag == 0)
  {
    res = res + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] == 1 && flag == 1)
  {
    res = res + "-";
    flag = 2; // �.���� ���� � res
  }
  else if(pgs[i] == 1 && flag == 3)
  {
    res = res + "," + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] == 0 && flag == 1)
  {
    flag = 3; // �.��� ������� ����� � res
  }
  else if(pgs[i] == 0 && flag == 2)
  {
    res = res + (i-1).toString(10);
    flag = 3; // �.��� ������� ����� � res
  }
}

print(res);

/*
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
*/

var inp = readline();

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }

/*
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
*/
}

print(pgs);

var inp = readline();

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }

/*
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
*/
}

print(inp);

var inp = readline();

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;

    if( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + buff;
    }
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }

/*
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
*/
}

print(res);

var inp = readline();

// ��������� ������

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<=n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }
}

//pgs[1] = 1;

// ��������� ���������

var flag = 0, k=0; // �� ���� ����� � res
n = pgs.length;

for(i=0;i<n;i++)
{
  if( pgs[i] == 1 && flag == 0)
  {
    res = res + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] == 1 && flag == 1)
  {
    res = res + "-";
    flag = 2; // �.���� ���� � res
  }
  else if(pgs[i] == 1 && flag == 3)
  {
    res = res + "," + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] != 1 && flag == 1)
  {
    flag = 3; // �.��� ������� ����� � res
  }
  else if(pgs[i] != 1 && flag == 2)
  {
    k = i-1;
    res = res + k.toString(10);
    flag = 3; // �.��� ������� ����� � res
  }
}

print(res);

var inp = readline();

// ��������� ������

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }
}

pgs[1] = 1;

// ��������� ���������

var flag = 0, k=0; // �� ���� ����� � res
n = pgs.length;

for(i=0;i<n;i++)
{
  if( pgs[i] == 1 && flag == 0)
  {
    res = res + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] == 1 && flag == 1)
  {
    res = res + "-";
    flag = 2; // �.���� ���� � res
  }
  else if(pgs[i] == 1 && flag == 3)
  {
    res = res + "," + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] != 1 && flag == 1)
  {
    flag = 3; // �.��� ������� ����� � res
  }
  else if(pgs[i] != 1 && flag == 2)
  {
    k = i-1;
    res = res + k.toString(10);
    flag = 3; // �.��� ������� ����� � res
  }
}

print(res);

var inp = readline();

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] != ",")
  {
    res = res + inp[i];
  }

/*
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
*/
}

print(res);

var inp = readline();

// ��������� ������

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }
}
pgs[ parseInt(buff) ] = 1;

// ��������� ���������

var flag = 0, k=0; // �� ���� ����� � res
n = pgs.length;

for(i=0;i<n;i++)
{
  if( pgs[i] == 1 && flag == 0)
  {
    res = res + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] == 1 && flag == 1)
  {
    res = res + "-";
    flag = 2; // �.���� ���� � res
  }
  else if(pgs[i] == 1 && flag == 3)
  {
    res = res + "," + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] != 1 && flag == 1)
  {
    flag = 3; // �.��� ������� ����� � res
  }
  else if(pgs[i] != 1 && flag == 2)
  {
    k = i-1;
    res = res + k.toString(10);
    flag = 3; // �.��� ������� ����� � res
  }
}

print(res);

var inp = readline();

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    res = res + buff;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }

/*
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
*/
}

print(res);

var inp = readline();

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    res = res + buff;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }

/*
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
*/
}

print(res);

var inp = readline();

var pgs=[], i=0, n = inp.length, buff = "", res = "";

/*
for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
}
*/

print(res);

var inp = readline();

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  /*
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
 */
}

print(res);

var inp = readline();

// ��������� ������

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";
  }
  else
  {
    buff = buff + inp[i];
  }
}

// ��������� ���������

var flag = 0, k=0; // �� ���� ����� � res
n = pgs.length;

for(i=0;i<n;i++)
{
  if( pgs[i] == 1 && flag == 0)
  {
    res = res + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] == 1 && flag == 1)
  {
    res = res + "-";
    flag = 2; // �.���� ���� � res
  }
  else if(pgs[i] == 1 && flag == 3)
  {
    res = res + "," + i.toString(10);
    flag = 1; // �.���� ����� � res
  }
  else if(pgs[i] != 1 && flag == 1)
  {
    flag = 3; // �.��� ������� ����� � res
  }
  else if(pgs[i] != 1 && flag == 2)
  {
    k = i-1;
    res = res + k.toString(10);
    flag = 3; // �.��� ������� ����� � res
  }
}

print(res);

var inp = readline();

var pgs=[], i=0, n = inp.length, buff = "", res = "";

for(i=0;i<n;i++)
{
  if( inp[i] == ",")
  {
    res = res + "-";
  }
  else
  {
    res = res + inp[i];
  }

/*
  if( inp[i] == ",")
  {
    pgs[ parseInt(buff) ] = 1;
    buff = "";

    if(i == 0 || res.length == 0)
    {
      res = res + buff;
    }
    elseif( i>0 && pgs[i-1]==1)
    {
      res == res + "-";
    }
    else
    {
      res = res + "," + buff;
    }
  }
  else
  {
    buff = buff + inp[i];
  }
*/
}

print(res);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var n = integers[0], m = integers[1], k = integers[2];
}

main();


"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
     let t = parseInt(readline());
     while(t--){
          let [n,x,y] = readline().trim().split(" ").map(cur=>parseInt(cur));
          let arr1 = readline().trim().split("").map(cur=>parseInt(cur));
          let arr2 = readline().trim().split("").map(cur=>parseInt(cur));
          let arr3 = [];
          for(let i=0;i<n;i++) arr3.push(arr1[i]^arr2[i]);
          let cnt = 0;
          for(let i=0;i<n;i++) if(arr3[i]===1) cnt++;
          if(cnt%2===1){
               console.log(-1);
               continue;
          }
          if(cnt===2){
               let flag = 1
               for(let i=0;i<n-1;i++){
                    if(arr3[i]===1 && arr3[i+1]===1){
                         console.log(Math.min(2*y,x));
                         flag = 0;
                         break;
                    }
               }
               if(flag===1) console.log(y);
          }
          else{
               console.log((cnt/2)*y);
          }
     }
};
solve();

'use strict';

var fs = require('fs');

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

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const N = 100010;
new Array(N);
      new Array(N);
function solve(read) {
  const rn = () => Number(read());
  const n = rn(),
        x = rn(),
        y = rn(),
        a = read().split('').map(Number),
        b = read().split('').map(Number);
  let c = [];
  for (let i = 0; i < n; i++) if (a[i] !== b[i]) c.push(i);
  if (c.length & 1) return -1;
  if (c.length === 2 && c[0] + 1 === c[1]) {
    if (x > 2 * y) return 2 * y;
    return x;
  }
  return c.length / 2 * y;
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      res[i] = s;
    }
    return res.join('\n');
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();


;(function () {
	var n = readline().split(' ');
	var k = +n[1];
	n = +n[0];

	var r = [];
	for (var i = 0; i < n - k - 1; i++) {
		r.push(i + 1);
	}

	for (var i = 0; i <= k; i++) {
		r.push(n - i);
	}

	print(r.join(' '));

}).call(this);

var l=readline().split(' ');
var n=+l[0];
var k=+l[1];
var ans=[];
var x=n-k;

for(var i=1; i<x; i++){
	ans.push(i);
}
for(var i=n; i>=x; i--){
	ans.push(i);
}

print(ans.join(' '));

var l=readline().split(' ');
var n=+l[0];
var k=+l[1];

var i=1;
var j=n;
var ans=[];

while(i<=j){
	if(k>0){
		k--;
		ans.push(j--);
		ans.push(i++);
	}else{
		ans.push(i++);
	}
}
print(ans.join(' '));


function solve() {
   function plus(a, b, c) {
      return ((a + b) % 1000000007 + c) % 1000000007;
   }
   var T = Number(read());
   var a = [1, 1, 3];
   var b = [0, 1, 1];
   var c = [0, 0, 1];
   var ans = [0, 0, 1];
   for (var i = 3; i < 2000000; i++) {
      a.push(plus(b[i - 1], b[i - 1], a[i - 1]));
      b.push(a[i - 1]);
      c.push(plus(b[i - 1], c[i - 1], 0));
      ans.push(plus(b[i - 1], ans[i - 3], 0));
   }

   for (var t = 0; t < T; t++) {
      var n = Number(read());
      write((ans[n - 1] * 4) % 1000000007);
   }
}

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');
         solve();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

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

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

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

const { KeyObject } = require("crypto");

var data = '';
var M = 1000000007;
process.stdin.setEncoding('utf8');

var res = [0, 0, 0, 4, 4];
for (var i = 5; i < 1 << 21; i++)
{
    if (i % 3 == 0)
        res[i] = res[i - 2] + res[i - 3] * 4 + res[i - 4] * 4 + 4;
    else
        res[i] = res[i - 1] + res[i - 2] * 2;
    res[i] = res[i] % M;
}

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

process.stdin.on('end', () =>
{
    var i = 1;
    var x = data.split(/\s+/).map(Number);
    for (var i = 1; i <= x[0]; i++)
    {
        console.log(res[x[i]]);
    }
});