This is an interactive problem.There is an unknown integer $$$x$$$ ($$$1\le x\le n$$$). You want to find $$$x$$$.At first, you have a set of integers $$$\{1, 2, \ldots, n\}$$$. You can perform the following operations no more than $$$10000$$$ times:  A $$$a$$$: find how many numbers are multiples of $$$a$$$ in the current set.  B $$$a$$$: find how many numbers are multiples of $$$a$$$ in this set, and then delete all multiples of $$$a$$$, but $$$x$$$ will never be deleted (even if it is a multiple of $$$a$$$). In this operation, $$$a$$$ must be greater than $$$1$$$.  C $$$a$$$: it means that you know that $$$x=a$$$. This operation can be only performed once. Remember that in the operation of type B $$$a>1$$$ must hold.Write a program, that will find the value of $$$x$$$.

The first line contains one integer $$$n$$$ ($$$1\le n\le 10^5$$$). The remaining parts of the input will be given throughout the interaction process.

NoteNote that to make the sample more clear, we added extra empty lines. You shouldn't print any extra empty lines during the interaction process.In the first test $$$n=10$$$ and $$$x=4$$$.Initially the set is: $$$\{1,2,3,4,5,6,7,8,9,10\}$$$.In the first operation, you ask how many numbers are multiples of $$$4$$$ and delete them. The answer is $$$2$$$ because there are two numbers divisible by $$$4$$$: $$$\{4,8\}$$$. $$$8$$$ will be deleted but $$$4$$$ won't, because the number $$$x$$$ will never be deleted. Now the set is $$$\{1,2,3,4,5,6,7,9,10\}$$$.In the second operation, you ask how many numbers are multiples of $$$2$$$. The answer is $$$4$$$ because there are four numbers divisible by $$$2$$$: $$$\{2,4,6,10\}$$$.In the third operation, you ask how many numbers are multiples of $$$8$$$. The answer is $$$0$$$ because there isn't any number divisible by $$$8$$$ in the current set.In the fourth operation, you know that $$$x=4$$$, which is the right answer.

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

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

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

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

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

// let input = '';
// process.stdin.on('data', c => input += c);
// process.stdin.on('end', main);
var gen = main(); gen.next();
process.stdin.on('data', c => gen.next(+c))
function* main() {
  // let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
  //   out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let p = [2, 3, 5];
  for (let i = 6; i < 1e5; i += 6) {
    let j, x = i + 1;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
    x = i + 5;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
  }
  let n = yield;
  let a = Arr(1, n, 1, i => 1);

  let p0 = [], remain;
  for (let i = 0; i <= 99; i++) {
    if (p[i] > n) break;
    console.log('B', p[i]);
    yield;
    For(p[i], n, p[i], i => { a[i] = 0 });
    console.log('A', p[i]);
    remain = yield;
    if (remain == 1) p0.push(p[i]);
  };
  let limit = p0[0] ? n / p0[0] : n;

  for (let i = 1; i <= 95; i++) {
    if (p[i * 100] > limit) break;
    for (let j = 0; j <= 99; j++) {
      let pp = p[i * 100 + j];
      if (!pp || pp > limit) break;
      console.log('B', pp);
      remain = yield;
      let s = 0;
      For(pp, n, pp, i => { s += a[i]; a[i] = 0; })
      if (remain > s) {
        p0.push(pp);
      }
    };
    if (limit == n) {
      console.log('A 1');
      remain = yield;
      if (remain > a.sum()) {
        for (let j = 0; j <= 99; j++) {
          let pp = p[i * 100 + j];
          if (!pp || pp > limit) break;
          console.log('A', pp);
          remain = yield;
          if (remain == 1) {
            if (limit == n) {
              console.log('C', pp);
              process.exit();
            } else p0.push(pp);
          }
        };
      }
    }
  }

  // console.log(p0);

  let pp = [];
  let x = 1;
  let gen = i => {
    if (i >= p0.length) return pp.push(x)
    for (let j = 0; ; j++) {
      x *= p0[i] ** j;
      if (x > n) {
        x /= p0[i] ** j;
        break;
      } else {
        gen(i + 1);
        x /= p0[i] ** j;
      }
    }
  }
  gen(0);
  pp.sort((a, b) => b - a);
  for (let x of pp) {
    console.log('A', x);
    remain = yield;
    if (remain == 1) {
      console.log('C', x);
      process.exit();
    }
  }
}

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

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

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

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

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

// let input = '';
// process.stdin.on('data', c => input += c);
// process.stdin.on('end', main);
var gen = main(); gen.next();
process.stdin.on('data', c => gen.next(+c))
function* main() {
  // let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
  //   out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let p = [2, 3, 5];
  for (let i = 6; i < 1e5; i += 6) {
    let j, x = i + 1;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
    x = i + 5;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
  }
  let n = yield;
  let a = Arr(1, n, 1, i => 1);

  for (let i = 0; i <= 99; i++) {
    if (p[i] > n) break;
    console.log('B', p[i]);
    yield;
    For(p[i], n, p[i], i => { a[i] = 0 })
  };
  console.log('A 1');
  let remain = yield;
  if (remain > a.sum()) {
    let p0 = [];
    for (let i = 0; i <= 4800; i++) {
      if (i > 99) {
        if (p[i] > n / 2) break;
        console.log('B', p[i]); yield
      }
      console.log('A', p[i]);
      remain = yield;
      if (remain == 1) p0.push(p[i]);
    };
    // console.log(p0);
    let pp = [];
    let x = 1;
    let gen = i => {
      if (i >= p0.length) return pp.push(x)
      for (let j = 0; ; j++) {
        x *= p0[i] ** j;
        if (x > n) {
          x /= p0[i] ** j;
          break;
        } else {
          gen(i + 1);
          x /= p0[i] ** j;
        }
      }
    }
    gen(0);
    pp.sort((a, b) => b - a);
    for (let x of pp) {
      console.log('A', x);
      remain = yield;
      if (remain == 1) {
        console.log('C', x);
        process.exit();
      }
    }
  } else {
    // x la so nguyen to > p[99]
    for (let i = 1; i <= 95; i++) {
      for (let j = 0; j <= 99; j++) {
        let pp = p[i * 100 + j] || 97;
        console.log('B', pp);
        yield;
        For(pp, n, pp, i => { a[i] = 0 })
      };
      console.log('A 1');
      remain = yield;
      if (remain == 1) {
        console.log('C 1');
        process.exit();
      }
      if (remain > a.sum()) {
        for (let j = 0; j <= 99; j++) {
          let pp = p[i * 100 + j] || 97;
          console.log('A', pp);
          remain = yield;
          if (remain == 1) {
            console.log('C', pp);
            process.exit();
          }
        };
      }
    }
  }
}

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

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

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

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

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

// let input = '';
// process.stdin.on('data', c => input += c);
// process.stdin.on('end', main);
var gen = main(); gen.next();
process.stdin.on('data', c => gen.next(+c))
function* main() {
  // let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
  //   out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let p = [2, 3, 5];
  for (let i = 6; i < 1e5; i += 6) {
    let j, x = i + 1;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
    x = i + 5;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
  }
  let n = yield;
  let a = Arr(1, n, 1, i => 1);

  for (let i = 0; i <= 99; i++) {
    if (p[i] > n) break;
    console.log('B', p[i]);
    yield;
    For(p[i], n, p[i], i => { a[i] = 0 })
  };
  console.log('A 1');
  let remain = yield;
  if (remain > a.sum()) {
    let p0 = [];
    for (let i = 0; i <= 4800; i++) {
      if (p[i] > n) break;
      if (i > 99) { console.log('B', p[i]); yield }
      console.log('A', p[i]);
      remain = yield;
      if (remain == 1) p0.push(p[i]);
    };
    // console.log(p0);
    let pp = [];
    let x = 1;
    let gen = i => {
      if (i >= p0.length) return pp.push(x)
      for (let j = 0; ; j++) {
        x *= p0[i] ** j;
        if (x > n) {
          x /= p0[i] ** j;
          break;
        } else {
          gen(i + 1);
          x /= p0[i] ** j;
        }
      }
    }
    gen(0);
    pp.sort((a, b) => b - a);
    for (let x of pp) {
      console.log('A', x);
      remain = yield;
      if (remain == 1) {
        console.log('C', x);
        process.exit();
      }
    }
  } else {
    // x la so nguyen to > p[99]
    for (let i = 1; i <= 95; i++) {
      for (let j = 0; j <= 99; j++) {
        let pp = p[i * 100 + j] || 97;
        console.log('B', pp);
        yield;
        For(pp, n, pp, i => { a[i] = 0 })
      };
      console.log('A 1');
      remain = yield;
      if (remain == 1) {
        console.log('C 1');
        process.exit();
      }
      if (remain > a.sum()) {
        for (let j = 0; j <= 99; j++) {
          let pp = p[i * 100 + j] || 97;
          console.log('A', pp);
          remain = yield;
          if (remain == 1) {
            console.log('C', pp);
            process.exit();
          }
        };
      }
    }
  }
}

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

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

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

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

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

// let input = '';
// process.stdin.on('data', c => input += c);
// process.stdin.on('end', main);
var gen = main(); gen.next();
process.stdin.on('data', c => gen.next(+c))
function* main() {
  // let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
  //   out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let p = [2, 3, 5];
  for (let i = 6; i < 1e5; i += 6) {
    let j, x = i + 1;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
    x = i + 5;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
  }
  let n = yield;
  let a = Arr(1, n, 1, i => 1);

  for (let i = 0; i <= 99; i++) {
    if (p[i] > n) break;
    console.log('B', p[i]);
    yield;
    For(p[i], n, p[i], i => { a[i] = 0 })
  };
  console.log('A 1');
  let remain = yield;
  if (remain > a.sum()) {
    let p0 = [];
    for (let i = 0; i <= 4800; i++) {
      if (p[i] > n) break;
      if (i > 99) {
        if (p[i] > n / 2) break;
        console.log('B', p[i]); yield
      }
      console.log('A', p[i]);
      remain = yield;
      if (remain == 1) p0.push(p[i]);
    };
    // console.log(p0);
    let pp = [];
    let x = 1;
    let gen = i => {
      if (i >= p0.length) return pp.push(x)
      for (let j = 0; ; j++) {
        x *= p0[i] ** j;
        if (x > n) {
          x /= p0[i] ** j;
          break;
        } else {
          gen(i + 1);
          x /= p0[i] ** j;
        }
      }
    }
    gen(0);
    pp.sort((a, b) => b - a);
    for (let x of pp) {
      console.log('A', x);
      remain = yield;
      if (remain == 1) {
        console.log('C', x);
        process.exit();
      }
    }
  } else {
    // x la so nguyen to > p[99]
    for (let i = 1; i <= 95; i++) {
      for (let j = 0; j <= 99; j++) {
        let pp = p[i * 100 + j] || 97;
        console.log('B', pp);
        yield;
        For(pp, n, pp, i => { a[i] = 0 })
      };
      console.log('A 1');
      remain = yield;
      if (remain == 1) {
        console.log('C 1');
        process.exit();
      }
      if (remain > a.sum()) {
        for (let j = 0; j <= 99; j++) {
          let pp = p[i * 100 + j] || 97;
          console.log('A', pp);
          remain = yield;
          if (remain == 1) {
            console.log('C', pp);
            process.exit();
          }
        };
      }
    }
  }
}

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

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

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

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

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

// let input = '';
// process.stdin.on('data', c => input += c);
// process.stdin.on('end', main);
var gen = main(); gen.next();
process.stdin.on('data', c => gen.next(+c))
function* main() {
  // let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
  //   out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let p = [2, 3, 5];
  for (let i = 6; i < 1e5; i += 6) {
    let j, x = i + 1;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
    x = i + 5;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
  }
  let n = yield;
  let a = Arr(1, n, 1, i => 1);

  for (let i = 0; i <= 99; i++) {
    if (p[i] > n) break;
    console.log('B', p[i]);
    yield;
    For(p[i], n, p[i], i => { a[i] = 0 })
  };
  console.log('A 1');
  let remain = yield;
  if (remain > a.sum()) {
    let p0 = [];
    for (let i = 0; i <= 1000; i++) {
      if (p[i] > n) break;
      if (i > 99) {
        if (p[i] > n / 2) break;
        console.log('B', p[i]); yield
      }
      console.log('A', p[i]);
      remain = yield;
      if (remain == 1) p0.push(p[i]);
    };
    // console.log(p0);
    let pp = [];
    let x = 1;
    let gen = i => {
      if (i >= p0.length) return pp.push(x)
      for (let j = 0; ; j++) {
        x *= p0[i] ** j;
        if (x > n) {
          x /= p0[i] ** j;
          break;
        } else {
          gen(i + 1);
          x /= p0[i] ** j;
        }
      }
    }
    gen(0);
    pp.sort((a, b) => b - a);
    for (let x of pp) {
      console.log('A', x);
      remain = yield;
      if (remain == 1) {
        console.log('C', x);
        process.exit();
      }
    }
  } else {
    // x la so nguyen to > p[99]
    for (let i = 1; i <= 95; i++) {
      for (let j = 0; j <= 99; j++) {
        let pp = p[i * 100 + j] || 97;
        console.log('B', pp);
        yield;
        For(pp, n, pp, i => { a[i] = 0 })
      };
      console.log('A 1');
      remain = yield;
      if (remain == 1) {
        console.log('C 1');
        process.exit();
      }
      if (remain > a.sum()) {
        for (let j = 0; j <= 99; j++) {
          let pp = p[i * 100 + j] || 97;
          console.log('A', pp);
          remain = yield;
          if (remain == 1) {
            console.log('C', pp);
            process.exit();
          }
        };
      }
    }
  }
}

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

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

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

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

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

// let input = '';
// process.stdin.on('data', c => input += c);
// process.stdin.on('end', main);
var gen = main(); gen.next();
process.stdin.on('data', c => gen.next(+c))
function* main() {
  // let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
  //   out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let p = [2, 3, 5];
  for (let i = 6; i < 1e5; i += 6) {
    let j, x = i + 1;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
    x = i + 5;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
  }
  let n = yield;
  let a = Arr(1, n, 1, i => 1);

  let p0 = [], remain;
  for (let i = 0; i <= 99; i++) {
    if (p[i] > n) break;
    console.log('B', p[i]);
    yield;
    For(p[i], n, p[i], i => { a[i] = 0 });
    console.log('A', p[i]);
    remain = yield;
    if (remain == 1) p0.push(p[i]);
  };
  let limit = p0[0] ? n / p0[0] : n;

  for (let i = 1; i <= 95; i++) {
    if (p[i * 100] > limit) break;
    for (let j = 0; j <= 99; j++) {
      let pp = p[i * 100 + j];
      if (!pp || pp > limit) break;
      console.log('B', pp);
      yield;
      For(pp, n, pp, i => { a[i] = 0 })
    };
    console.log('A 1');
    remain = yield;
    if (remain > a.sum()) {
      for (let j = 0; j <= 99; j++) {
        let pp = p[i * 100 + j];
        if (!pp || pp > limit) break;
        console.log('A', pp);
        remain = yield;
        if (remain == 1) {
          if (p0 == n) {
            console.log('C', pp);
            process.exit();
          } else p0.push(pp);
        }
      };
    }
  }

  // console.log(p0);

  let pp = [];
  let x = 1;
  let gen = i => {
    if (i >= p0.length) return pp.push(x)
    for (let j = 0; ; j++) {
      x *= p0[i] ** j;
      if (x > n) {
        x /= p0[i] ** j;
        break;
      } else {
        gen(i + 1);
        x /= p0[i] ** j;
      }
    }
  }
  gen(0);
  pp.sort((a, b) => b - a);
  for (let x of pp) {
    console.log('A', x);
    remain = yield;
    if (remain == 1) {
      console.log('C', x);
      process.exit();
    }
  }
}

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

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

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

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

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

// let input = '';
// process.stdin.on('data', c => input += c);
// process.stdin.on('end', main);
var gen = main(); gen.next();
process.stdin.on('data', c => gen.next(+c))
function* main() {
  // let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
  //   out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let p = [2, 3, 5];
  for (let i = 6; i < 1e5; i += 6) {
    let j, x = i + 1;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
    x = i + 5;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
  }
  let n = yield;
  let a = Arr(1, n, 1, i => 1);

  let p0 = [], remain;
  for (let i = 0; i <= 99; i++) {
    if (p[i] > n) break;
    console.log('B', p[i]);
    yield;
    For(p[i], n, p[i], i => { a[i] = 0 });
    console.log('A', p[i]);
    remain = yield;
    if (remain == 1) p0.push(p[i]);
  };
  let limit = p0[0] ? n / p0[0] : n;

  for (let i = 1; i <= 95; i++) {
    if (p[i * 100] > limit) break;
    for (let j = 0; j <= 99; j++) {
      let pp = p[i * 100 + j];
      if (!pp || pp > limit) break;
      console.log('B', pp);
      yield;
      For(pp, n, pp, i => { a[i] = 0 })
    };
    console.log('A 1');
    remain = yield;
    if (remain == 1) {
      console.log('C 1');
      process.exit();
    }
    if (remain > a.sum()) {
      for (let j = 0; j <= 99; j++) {
        let pp = p[i * 100 + j];
        if (!pp || pp > limit) break;
        console.log('A', pp);
        remain = yield;
        if (remain == 1) {
          p0.push(pp);
        }
      };
    }
  }

  // console.log(p0);

  let pp = [];
  let x = 1;
  let gen = i => {
    if (i >= p0.length) return pp.push(x)
    for (let j = 0; ; j++) {
      x *= p0[i] ** j;
      if (x > n) {
        x /= p0[i] ** j;
        break;
      } else {
        gen(i + 1);
        x /= p0[i] ** j;
      }
    }
  }
  gen(0);
  pp.sort((a, b) => b - a);
  for (let x of pp) {
    console.log('A', x);
    remain = yield;
    if (remain == 1) {
      console.log('C', x);
      process.exit();
    }
  }
}

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

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

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

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

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

// let input = '';
// process.stdin.on('data', c => input += c);
// process.stdin.on('end', main);
var gen = main(); gen.next();
process.stdin.on('data', c => gen.next(+c))
function* main() {
  // let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
  //   out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let p = [2, 3, 5];
  for (let i = 6; i < 1e5; i += 6) {
    let j, x = i + 1;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
    x = i + 5;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
  }
  let n = yield;
  let a = Arr(1, n, 1, i => 1);

  let p0 = [], remain;
  for (let i = 0; i <= 99; i++) {
    if (p[i] > n) break;
    console.log('B', p[i]);
    yield;
    For(p[i], n, p[i], i => { a[i] = 0 });
    console.log('A', p[i]);
    remain = yield;
    if (remain == 1) p0.push(p[i]);
  };
  let limit = p0[0] ? n / p0[0] : n;

  for (let i = 1; i <= 95; i++) {
    if (p[i * 100] > limit) break;
    for (let j = 0; j <= 99; j++) {
      let pp = p[i * 100 + j];
      if (!pp || pp > limit) break;
      console.log('B', pp);
      yield;
      For(pp, n, pp, i => { a[i] = 0 })
    };
    console.log('A 1');
    remain = yield;
    if (remain > a.sum()) {
      for (let j = 0; j <= 99; j++) {
        let pp = p[i * 100 + j];
        if (!pp || pp > limit) break;
        console.log('A', pp);
        remain = yield;
        if (remain == 1) {
          if (limit == n) {
            console.log('C', pp);
            process.exit();
          } else p0.push(pp);
        }
      };
    }
  }

  // console.log(p0);

  let pp = [];
  let x = 1;
  let gen = i => {
    if (i >= p0.length) return pp.push(x)
    for (let j = 0; ; j++) {
      x *= p0[i] ** j;
      if (x > n) {
        x /= p0[i] ** j;
        break;
      } else {
        gen(i + 1);
        x /= p0[i] ** j;
      }
    }
  }
  gen(0);
  pp.sort((a, b) => b - a);
  for (let x of pp) {
    console.log('A', x);
    remain = yield;
    if (remain == 1) {
      console.log('C', x);
      process.exit();
    }
  }
}

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

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

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

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

// let p = [2, 3, 5];
// for (let i = 6; i < 1e5; i += 6) {
//   let j, x = i + 1;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
//   x = i + 5;
//   for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
//   if (x % p[j] != 0) p.push(x);
// }

// let input = '';
// process.stdin.on('data', c => input += c);
// process.stdin.on('end', main);
var gen = main(); gen.next();
process.stdin.on('data', c => gen.next(+c))
function* main() {
  // let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
  //   out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let p = [2, 3, 5];
  for (let i = 6; i < 1e5; i += 6) {
    let j, x = i + 1;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
    x = i + 5;
    for (j = 0; p[j] * p[j] <= x; j++) if (x % p[j] == 0) break;
    if (x % p[j] != 0) p.push(x);
  }
  let n = yield;
  let a = Arr(1, n, 1, i => 1);

  for (let i = 0; i <= 99; i++) {
    if (p[i] > n) break;
    console.log('B', p[i]);
    yield;
    For(p[i], n, p[i], i => { a[i] = 0 })
  };
  console.log('A 1');
  let remain = yield;
  if (remain > a.sum()) {
    let p0 = [];
    for (let i = 0; i <= 4800; i++) {
      if (i > 99) {
        if (p0[i] > n / 2) break;
        console.log('B', p[i]); yield
      }
      console.log('A', p[i]);
      remain = yield;
      if (remain == 1) p0.push(p[i]);
    };
    // console.log(p0);
    let pp = [];
    let x = 1;
    let gen = i => {
      if (i >= p0.length) return pp.push(x)
      for (let j = 0; ; j++) {
        x *= p0[i] ** j;
        if (x > n) {
          x /= p0[i] ** j;
          break;
        } else {
          gen(i + 1);
          x /= p0[i] ** j;
        }
      }
    }
    gen(0);
    pp.sort((a, b) => b - a);
    for (let x of pp) {
      console.log('A', x);
      remain = yield;
      if (remain == 1) {
        console.log('C', x);
        process.exit();
      }
    }
  } else {
    // x la so nguyen to > p[99]
    for (let i = 1; i <= 95; i++) {
      for (let j = 0; j <= 99; j++) {
        let pp = p[i * 100 + j] || 97;
        console.log('B', pp);
        yield;
        For(pp, n, pp, i => { a[i] = 0 })
      };
      console.log('A 1');
      remain = yield;
      if (remain == 1) {
        console.log('C 1');
        process.exit();
      }
      if (remain > a.sum()) {
        for (let j = 0; j <= 99; j++) {
          let pp = p[i * 100 + j] || 97;
          console.log('A', pp);
          remain = yield;
          if (remain == 1) {
            console.log('C', pp);
            process.exit();
          }
        };
      }
    }
  }
}


Seiji Maki doesn't only like to observe relationships being unfolded, he also likes to observe sequences of numbers, especially permutations. Today, he has his eyes on almost sorted permutations.A permutation $$$a_1, a_2, \dots, a_n$$$ of $$$1, 2, \dots, n$$$ is said to be almost sorted if the condition $$$a_{i + 1} \ge a_i - 1$$$ holds for all $$$i$$$ between $$$1$$$ and $$$n - 1$$$ inclusive.Maki is considering the list of all almost sorted permutations of $$$1, 2, \dots, n$$$, given in lexicographical order, and he wants to find the $$$k$$$-th permutation in this list. Can you help him to find such permutation?Permutation $$$p$$$ is lexicographically smaller than a permutation $$$q$$$ if and only if the following holds: in the first position where $$$p$$$ and $$$q$$$ differ, the permutation $$$p$$$ has a smaller element than the corresponding element in $$$q$$$.

The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$) — the number of test cases. Each test case consists of a single line containing two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le k \le 10^{18}$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, print a single line containing the $$$k$$$-th almost sorted permutation of length $$$n$$$ in lexicographical order, or $$$-1$$$ if it doesn't exist.

NoteFor the first and second test, the list of almost sorted permutations with $$$n = 1$$$ is $$$\{[1]\}$$$.For the third and fifth test, the list of almost sorted permutations with $$$n = 3$$$ is $$$\{[1, 2, 3], [1, 3, 2], [2, 1, 3], [3, 2, 1]\}$$$.

'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 = () => Number(read());
  const rb = () => BigInt(read());
  let n = rn(),
      k = rb() - 1n;
  const res = new Array(n).fill(0);
  let max = 2n ** BigInt(n - 1) - 1n;
  if (k > max) return -1;
  if (k === max) {
    let pre = n;
    for (let i = 0; i < n; i++) {
      res[i] = pre--;
    }
    return res.join(' ');
  }
  const s = k.toString(2).padStart(n - 1, '0').split('').map(Number);
  let pre = 1;
  for (let i = 0; i < n - 1; i++) {
    if (s[i] === 1) {
      let j = i;
      while (j < n - 1 && s[j] === 1) j++;
      for (let l = j; l >= i; l--) res[l] = pre++;
      i = j;
    } else {
      res[i] = pre++;
    }
  }
  if (s[n - 2] === 0) res[n - 1] = n;
  return res.join(' ');
}

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 : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    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);
}();


There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.Tablecity can be represented as 1000 × 2 grid, where every cell represents one district. Each district has its own unique name “(X, Y)”, where X and Y are the coordinates of the district in the grid. The thief’s movement is as Every hour the thief will leave the district (X, Y) he is currently hiding in, and move to one of the districts: (X - 1, Y), (X + 1, Y), (X - 1, Y - 1), (X - 1, Y + 1), (X + 1, Y - 1), (X + 1, Y + 1) as long as it exists in Tablecity. Below is an example of thief’s possible movements if he is located in district (7,1):Albert has enough people so that every hour he can pick any two districts in Tablecity and fully investigate them, making sure that if the thief is located in one of them, he will get caught. Albert promised the President that the thief will be caught in no more than 2015 hours and needs your help in order to achieve that.

The first line of output contains integer N – duration of police search in hours. Each of the following N lines contains exactly 4 integers Xi1, Yi1, Xi2, Yi2 separated by spaces, that represent 2 districts (Xi1, Yi1), (Xi2, Yi2) which got investigated during i-th hour. Output is given in chronological order (i-th line contains districts investigated during i-th hour) and should guarantee that the thief is caught in no more than 2015 hours, regardless of thief’s initial position and movement.   N ≤ 2015  1 ≤ X ≤ 1000  1 ≤ Y ≤ 2

В этой задаче нет примеров ввода-вывода.
This problem doesn't have sample input and output.

Смотрите замечание ниже.
See the note below.

NoteLet's consider the following output:25 1 50 28 1 80 2This output is not guaranteed to catch the thief and is not correct. It is given to you only to show the expected output format. There exists a combination of an initial position and a movement strategy such that the police will not catch the thief.Consider the following initial position and thief’s movement:In the first hour, the thief is located in district (1,1). Police officers will search districts (5,1) and (50,2) and will not find him.At the start of the second hour, the thief moves to district (2,2). Police officers will search districts (8,1) and (80,2) and will not find him.Since there is no further investigation by the police, the thief escaped!


Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the dishes are different, because Mr. Apple doesn't like to eat the same food. For each pair of dishes from different days he remembers exactly which was better, or that they were of the same quality. After this the gourmet evaluates each dish with a positive integer.Once, during a revision of a restaurant of Celtic medieval cuisine named «Poisson», that serves chestnut soup with fir, warm soda bread, spicy lemon pie and other folk food, Mr. Apple was very pleasantly surprised the gourmet with its variety of menu, and hence ordered too much. Now he's confused about evaluating dishes.The gourmet tasted a set of $$$n$$$ dishes on the first day and a set of $$$m$$$ dishes on the second day. He made a table $$$a$$$ of size $$$n \times m$$$, in which he described his impressions. If, according to the expert, dish $$$i$$$ from the first set was better than dish $$$j$$$ from the second set, then $$$a_{ij}$$$ is equal to ">", in the opposite case $$$a_{ij}$$$ is equal to "<". Dishes also may be equally good, in this case $$$a_{ij}$$$ is "=".Now Mr. Apple wants you to help him to evaluate every dish. Since Mr. Apple is very strict, he will evaluate the dishes so that the maximal number used is as small as possible. But Mr. Apple also is very fair, so he never evaluates the dishes so that it goes against his feelings. In other words, if $$$a_{ij}$$$ is "<", then the number assigned to dish $$$i$$$ from the first set should be less than the number of dish $$$j$$$ from the second set, if $$$a_{ij}$$$ is ">", then it should be greater, and finally if $$$a_{ij}$$$ is "=", then the numbers should be the same.Help Mr. Apple to evaluate each dish from both sets so that it is consistent with his feelings, or determine that this is impossible.

The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of dishes in both days. Each of the next $$$n$$$ lines contains a string of $$$m$$$ symbols. The $$$j$$$-th symbol on $$$i$$$-th line is $$$a_{ij}$$$. All strings consist only of "<", ">" and "=".

The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise. If case an answer exist, on the second line print $$$n$$$ integers — evaluations of dishes from the first set, and on the third line print $$$m$$$ integers — evaluations of dishes from the second set.

NoteIn the first sample, all dishes of the first day are better than dishes of the second day. So, the highest score will be $$$2$$$, for all dishes of the first day.In the third sample, the table is contradictory — there is no possible evaluation of the dishes that satisfies it.

var nums = readline().split(" ").map(function(x) { return parseInt(x); });
var n = nums[0], m = nums[1];
var s = Array(n).fill([]);
for (var i=0; i<n; i++) {
	var q = readline();
	s[i] = [];
	for (var j=0; j<m; j++) s[i].push(q[j]);
}
var rank = Array(n+m).fill(0);
var ppp = Array(n+m).fill(0);
for (var i=0; i<n+m; i++) ppp[i] = i;

find_set = function(v) {
	if (v !== ppp[v])
		ppp[v] = find_set(ppp[v]);
	return ppp[v];
};

Union = function(x,y) {
	if (rank[x] < rank[y])
		ppp[x] = y;
	else
		ppp[y] = x;
	rank[x] += rank[y]===rank[x];
};

for (var i=0; i<n; i++)
	for (var j=0; j<m; j++)
		if (s[i][j] === '=')
			Union(find_set(i), find_set(j+n));

var e = Array(n+m).fill([]);
for (var i=0; i<n+m; i++) {
	var t = [];
	e[i] = t;
}

add_edge = function(a,b) {
	e[a].push(b);
};

for (var i=0; i<n; i++)
	for (var j=0; j<m; j++)
		if (s[i][j] === '<')
			add_edge(find_set(i), find_set(j+n));
		else if (s[i][j] === '>')
			add_edge(find_set(j+n), find_set(i));

var nnew = Array(n+m).fill(0);
var lst = [];
for (var i=0; i<n+m; i++)
	if (nnew[find_set(i)] === 0) {
		lst.push(find_set(i));
		nnew[find_set(i)] = 1;
	}

nnew = Array(n+m).fill(0);

/*
write(" LST = ", lst);
write("\n");

write(" Edges = ");
write(" n = ",n);
write(" m = ",m);
for (var i=0; i<n+m; i++) {
    var t = [];
    write(" i = ",i," e = ",e[i]);
    //for (var j=0; j<e[i].length; i++) t.push(e[i][j]);
    //write(t.join(" "));
    write("\n");
}
write("\n");*/

var ans = [];

var Ok = 1;
dfs = function(v) {
	if (!Ok)
		return;
	nnew[v] = 1;
	for (var i=0; i<e[v].length; i++) {
		var to = e[v][i];
		if (!nnew[to])
			dfs(to);
		else {
			if (nnew[to] == 1) {
			    Ok = 0;
			    return;
			}
		}
	}
	if (!Ok)
		return;
	ans.push(v);
	nnew[v] = 2;
};

for (var i=0; i<n+m; i++)
	if (!nnew[i])
		dfs(i);

if (!Ok) {
	write("No");
}
else {
	ans.reverse();
//write(" Ans = ", ans);
//write("\n");
	write("Yes");
	var sum = Array(n+m).fill(0);
	for (var i=0; i<ans.length; i++) {
		if (sum[ans[i]] === 0)
			sum[ans[i]] = 1;
		for (var j=0; j<e[ans[i]].length; j++)
			sum[e[ans[i]][j]] = Math.max(sum[e[ans[i]][j]], sum[ans[i]] + 1);
	}
	var real_ans = Array(n+m).fill(1);
	for (var i=0; i<n+m; i++)
		real_ans[i] = sum[find_set(i)];
	var p1 = [];
	for (var i=0; i<n; i++) p1.push(real_ans[i]);
	var p2 = [];
	for (var i=n; i<n+m; i++) p2.push(real_ans[i]);
	write("\n");
	write(p1.join(" "));
	write("\n");
	write(p2.join(" "));
}


Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter. Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.You are given an encoding s of some word, your task is to decode it.

The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word. The second line contains the string s of length n consisting of lowercase English letters — the encoding.

NoteIn the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.

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

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

  const arr = [...str];
  let ans = arr[0];
  arr.shift();

  while (arr.length) {
    if (arr.length % 2 === 0) {
      ans = arr[0] + ans;
    }
    else {
      ans = ans + arr[0];
    }

    arr.shift();
  }

  console.log(ans);

  c++;
});

const input = [];

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

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

function removeLetter(str, pos) {
    return str.substring(0, pos-1)+str.substring(pos);
}

RL.on('close', () => {
    const n = parseInt(input[0], 10);
    let str = input[1];

    let answer = ''; let mode = (str.length % 2 === 0) ? 1 : 0;
    for(let i = 0; i < n; i += 1) {
        if(mode && i !== 0){
            answer = str.charAt(i) + answer;
            mode = !mode;
        } else if (!mode  && i !== 0) {
            answer += str.charAt(i);
            mode = !mode;
        } else if(i === 0) {
            answer = str.charAt(0);
        }
    }
    global.console.log(answer.split("").reverse().join(""));
});

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

let currentLine = 0;
let inputString = "";

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

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

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

/******** Main function*************/

function main() {
  var n = +readLine();
  var str = readLine().split("");

  var newStr = [];

  if (n % 2 == 1) {
    for (var i = 1; i <= n; i++) {
      if (i % 2 == 1) {
        newStr.push(str[i - 1]);
      }
      if (i % 2 === 0) {
        newStr.unshift(str[i - 1]);
      }
    }
  }
  if (n % 2 === 0) {
    for (var j = 1; j <= n; j++) {
      if (j % 2 === 0) {
        newStr.push(str[j - 1]);
      }
      if (j % 2 == 1) {
        newStr.unshift(str[j - 1]);
      }
    }
  }

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

var n=parseInt(readline());
var inp=readline(),op="";
var i=n-2;
if(inp.length%2===0){
while(i>=0){
op+=inp[i];
i-=2;
}i=1;while(i<n){
	op+=inp[i];
	i+=2;
}
}else{
while(i>0){
op+=inp[i];
i-=2;
}i=0;while(i<n){
	op+=inp[i];
	i+=2;
}
}

print(op);

function decodeWord(encodedWord, lengthOfWord){
    var arrayForWord = Array(lengthOfWord);
    var left = 0;
    var right = lengthOfWord-1;
    var first = false;
    var last = true;

    for(var i=encodedWord.length-1; i>=0; i--){
        if(first === false && last === true){
            arrayForWord[right] = encodedWord[i];
            right--;
            first = true;
            last = false;

        }else if( first === true && last === false){
            arrayForWord[left] = encodedWord[i];
            left++;

            first = false;
            last = true;
        }

    }

    print( arrayForWord.join('') );

}
var length = readline();
var input = readline();
decodeWord(input, length)

var len = parseInt(readline());
var str = readline();

var res = '';

for (var i = 0; i < len; i++) {
  if (len%2 === 0) {
    i%2 !== 0 ? res += str[i] : res = str[i] + res;
  } else {
    i%2 === 0 ? res += str[i] : res = str[i] + res;
  }
}

print(res);

var n = readline().split(' ')[0];
var s = readline().split(' ')[0];
var a = "";
var b = "";
for (var i = 0; i < n; i++) {
	if (i%2 == 0)
    	a += s[i];
    else
    	b = s[i]+b;
}
a = b+a;
if (s.length % 2 == 0)
 a = a.split("").reverse().join("");
print(a)

var l = readline();
l = parseInt(l);

var w = readline();
var a = w.split('');

var r = '';
var p = 'd';
if (l % 2) {
    p = 's';
}
a.forEach(l => {
    if (p == 's') {
        r = r + l;
        p = 'd';
    } else {
        r = l + r;
        p = 's';
    }
});

print(r);

var n = parseInt(readline());
var s = readline();
var result = [];
var c = 0;
var stringResult = "";

var median = Math.ceil(n / 2) - 1;
result[median] = s[0];

if(n % 2 == 1)
{
    for(var i = 1; i < median + 1; i++)
    {
        result[median - i] = s[i + c];
        result[median + i] = s[i + 1 + c];
        c++;
    }
}
else
{
    for(var i = 1; i < median + 1; i++)
    {
        result[median + i] = s[i + c];
        result[median - i] = s[i + 1 + c];
        c++;
    }
    result[n - 1] = s[n - 1];
}

for(var i = 0; i < n; i++)
    stringResult += result[i];

print(stringResult);

var s = readline().split(' ')[0];
var a = "";
var b = "";
for (var i = 0; i < s.length; i++) {
	if (i%2 == 0)
    	a += s[i];
    else
    	b = s[i]+b;
}
print(b+a)

var n = readline().split(' ')[0];
var s = readline().split(' ')[0];
var a = "";
var b = "";
for (var i = 0; i < n; i++) {
	if (i%2 == 0)
    	a += s[i];
    else
    	b = s[i]+b;
}
print(b+a)

var n = parseInt(readline());
var s = readline();
var result = ["a", "a", "a", "a", "a"];
var c = 0;
var stringResult = "";

var median = Math.ceil(n / 2) - 1;
result[median] = s[0];

if(n % 2 == 1)
{
    for(var i = 0; i < median + 1; i++)
    {
        result[median - i] = s[i + c];
        result[median + i] = s[i + 1 + c];
        c++;
    }
}
else
{
    for(var i = 0; i < median + 1; i++)
    {
        result[median + i] = s[i + c];
        result[median - i] = s[i + 1 + c];
        c++;
    }
    result[n - 1] = s[n - 1];
}

for(var i = 0; i < n; i++)
    stringResult += result[i];

print(stringResult);

var n = parseInt(readline());
var s = readline();
var result = [];
var c = 0;
var stringResult = "";

var median = Math.ceil(n / 2) - 1;
result[median] = s[0];

if(n % 2 == 1)
{
    for(var i = 0; i < median + 1; i++)
    {
        result[median - i] = s[i + c];
        result[median + i] = s[i + 1 + c];
        c += 1;
    }
}
else
{
    for(var i = 0; i < median + 1; i++)
    {
        result[median + i] = s[i + c];
        result[median - i] = s[i + 1 + c];
        c += 1;
    }
    result[n - 1] = s[n - 1];
}

for(var i = 0; i < n; i++)
    stringResult += result[i];

print(stringResult);


Let's define a string <x> as an opening tag, where x is any small letter of the Latin alphabet. Each opening tag matches a closing tag of the type </x>, where x is the same letter.Tegs can be nested into each other: in this case one opening and closing tag pair is located inside another pair.Let's define the notion of a XML-text:   an empty string is a XML-text  if s is a XML-text, then s'=<a>+s+</a> also is a XML-text, where a is any small Latin letter  if s1, s2 are XML-texts, then s1+s2 also is a XML-text You are given a XML-text (it is guaranteed that the text is valid), your task is to print in the following form:   each tag (opening and closing) is located on a single line  print before the tag 2 * h spaces, where h is the level of the tag's nestedness.

The input data consists on the only non-empty string — the XML-text, its length does not exceed 1000 characters. It is guaranteed that the text is valid. The text contains no spaces.

Print the given XML-text according to the above-given rules.

var text = readline();
var arr = text.match(/<\/?[a-z]>/g).map(function(t){return t.replace(/<|>/g, '')});
var hash = {};
var currIndent = 0;
for (var i = 0; i < arr.length; i++) {
    var val = arr[i];
    if (val.search('/') != -1) {
        print(' '.repeat(hash[val.replace('/', '')].pop()) + '<' + val + '>');
        currIndent -= 2;
    } else {
        print(' '.repeat(currIndent) + '<' + val + '>');
        hash[val] = hash[val] || [];
        hash[val].push(currIndent);
        currIndent += 2;
    }
}

var text = readline();
var arr = text.match(/<\/?[a-z]>/g).map(function(t){return t.replace(/<|>/g, '')});
var hash = {};
var currIndent = 0;
for (var i = 0; i < arr.length; i++) {
    var val = arr[i];
    if (val.search('/') != -1) {
        print(' '.repeat(hash[val.replace('/', '')]) + '<' + val + '>');
        currIndent -= 2;
    } else {
        print(' '.repeat(currIndent) + '<' + val + '>');
        hash[val] = currIndent;
        currIndent += 2;
    }
}


You are given two integers $$$n$$$ and $$$k$$$. Your task is to find if $$$n$$$ can be represented as a sum of $$$k$$$ distinct positive odd (not divisible by $$$2$$$) integers or not.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. The next $$$t$$$ lines describe test cases. The only line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n, k \le 10^7$$$).

For each test case, print the answer — "YES" (without quotes) if $$$n$$$ can be represented as a sum of $$$k$$$ distinct positive odd (not divisible by $$$2$$$) integers and "NO" otherwise.

NoteIn the first test case, you can represent $$$3$$$ as $$$3$$$.In the second test case, the only way to represent $$$4$$$ is $$$1+3$$$.In the third test case, you cannot represent $$$10$$$ as the sum of three distinct positive odd integers.In the fourth test case, you can represent $$$10$$$ as $$$3+7$$$, for example.In the fifth test case, you can represent $$$16$$$ as $$$1+3+5+7$$$.In the sixth test case, you cannot represent $$$16$$$ as the sum of five distinct positive odd integers.

var inputnumber = readline();
var least = 0;
for(var i = 0; i < inputnumber ; i++){
    var arr = readline().split(" ");
    var num = arr[0]
    var n = arr [1];
    least = (2+(n-1)*2)*n/2;
    if(least > num || n%2 != num%2){
        print("NO");
    }else{
        print("YES");
    };
};

var len = readline()
for (var i = 0;i < len;i ++) {
  var item = readline().split(' ');
  if (item[0]%2 == item[1]%2 && Number(item[0]) >= Number(item[1]) * Number(item[1])) {
    print('YES')
  } else {print('NO')}
}

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [n, k] = lines[j+1].split(' ').map(x => +x)
    const r = n-k
    if (r >= 0 && r%2 == 0 && n >= k*k) {
      console.log('YES')
    } else {
      console.log('NO')
    }
  }
}

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

'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(/\W+/) // splits at spaces or new lines
    .map(string => {
      return string.trim();
    });

  main();
});

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

function main() {
  const n = readline(); // number of test cases

  for (let i = 0; i < n; i++) {
    const n = readline(); // test input 1
    const k = readline(); // test input 2
    const result = solution(n, k);
    console.log(result);
  }
}

function solution(n, k) {
  if (k * k <= n && n % 2 === k % 2) return 'YES';
  else return 'NO';
}

// console.log(solution(16, 4));

// Q: https://codeforces.com/contest/1327/problem/A

const readline = require('readline');

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

let input = [];

rl.on('line', lineInput => {
	input.push(lineInput);
});

rl.on('close', () => {
    const test = parseInt(input[0]);
    let n, k;
    for (let t = 0; t < test; t++) {
        [n, k] = input[t + 1].split(' ').map((a) => parseInt(a));
        console.log(solution(n, k));
    }
});

function solution(n, k) {
    if (Math.pow(k, 2) > n || n%2 !== k%2) {
        return 'NO';
    }
    return 'YES'
}

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

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  let t = readInt()
  while(t--) {
    const [n, k] = readInts()
    if(n % 2 === k % 2) {
      if(k * k <= n) {
        wr('YES')
      }
      else wr('NO')
    }
    else wr('NO')
  }
}

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [a, b] = lines[j+1].split(' ').map(x => +x)
    if (((a & 1) == (b & 1)) && (a >= (2 + (b - 1) * 2) * b / 2)) {
      console.log('YES')
    } else {
      console.log('NO')
    }
  }
}

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

var inputnumber = readline();
var least = 0;
for(var i = 0; i < inputnumber ; i++){
    var arr = readline().split(" ");
    var num = arr[0]
    var n = arr [1];
    least = (2+(n-1)*2)*n/2;
    if(least > num || n%2 != num%2){
        print("FALSE");
    }else{
        print("TRUE");
    };
};

var len = readline()
for (var i = 0;i < len;i ++) {
  var item = readline().split(' ');
  if (item[0]%2 == item[1]%2 && item[0] >= item[1]) {
    print('YES')
  } else {print('NO')}
}

var len = readline()
for (var i = 0;i < len;i ++) {
  var item = readline().split(' ');
  if (item[0]%2 == item[1]%2 && Number(item[0]) >= Number(item[1])) {
    print('YES')
  } else {print('NO')}
}

var arr = readline().split(' ')
for (var i = 1;i < arr.length;i ++) {
  var item = arr[i].split(' ');
  if (item[0]%2 == item[1]%2) {
    print('YES')
  } else {print('NO')}
}

var len = readline()
for (var i = 0;i < len;i ++) {
  var item = readline().split(' ');
  if (item[0]%2 == item[1]%2) {
    print('YES')
  } else {print('NO')}
}

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [n, k] = lines[j+1].split(' ').map(x => +x)
    const r = n-(k-1)
    if (r >= 0 && r%2 !== 0) {
      console.log('YES')
    } else {
      console.log('NO')
    }
  }
}

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

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [n, k] = lines[j+1].split(' ').map(x => +x)
    const r = n-k
    if (r >= 0 && r%2 === 0 && n > Math.pow(2, k)) {
      console.log('YES')
    } else {
      console.log('NO')
    }
  }
}

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

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [n, k] = lines[j+1].split(' ').map(x => +x)
    const r = n-k
    if (r >= 0 && r%2 == 0 && Math.pow(2, k) <= n) {
      console.log('YES')
    } else {
      console.log('NO')
    }
  }
}

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

const processData = (lines) => {
  const num = +lines[0]
  for (let j =1; j<num; j++) {
    const [n, k] = lines[j+1].split(' ').map(x => +x)
    const r = n-(k-1)
    if (r <= 0 || r%2 === 0) {
      console.log('NO')
    } else {
      console.log('YES')
    }
  }
}

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

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [n, k] = lines[j+1].split(' ').map(x => +x)
    const r = n-(k-1)
    if (r <= 0 || r%2 === 0) {
      console.log('NO')
    } else {
      console.log('YES')
    }
  }
}

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

'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(/\W+/) // splits at spaces or new lines
    .map(string => {
      return string.trim();
    });

  main();
});

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

function main() {
  const n = readline(); // number of test cases

  for (let i = 0; i < n; i++) {
    const n = readline(); // test input 1
    const k = readline(); // test input 2
    const result = solution(n, k);
    console.log(result);
  }
}

function solution(a, b) {
  if (a % b === 0) return 'YES';
  else {
    return 'NO';
  }
}

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [n, k] = lines[j+1].split(' ').map(x => +x)
    const r = n-k
    if (r >= 0 && r%2 === 0 ) {
      console.log('YES')
    } else {
      console.log('NO')
    }
  }
}

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

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [n, k] = lines[j+1].split(' ').map(x => +x)
    if (n%2 === k%2 && n >= k) {
      console.log('YES')
    } else {
      console.log('NO')
    }
  }
}

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

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [a, b] = lines[j+1].split(' ').map(x => +x)
    if ((a & 1) == (b & 1) && (a >= (2 + b - 1) * b / 2)) {
      console.log('YES')
    } else {
      console.log('NO')
    }
  }
}

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


Recently, Vlad has been carried away by spanning trees, so his friends, without hesitation, gave him a connected weighted undirected graph of $$$n$$$ vertices and $$$m$$$ edges for his birthday.Vlad defined the ority of a spanning tree as the bitwise OR of all its weights, and now he is interested in what is the minimum possible ority that can be achieved by choosing a certain spanning tree. A spanning tree is a connected subgraph of a given graph that does not contain cycles.In other words, you want to keep $$$n-1$$$ edges so that the graph remains connected and the bitwise OR weights of the edges are as small as possible. You have to find the minimum bitwise OR itself.

The first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. An empty line is written in front of each test case. This is followed by two numbers $$$n$$$ and $$$m$$$ ($$$3 \le n \le 2 \cdot 10^5, n - 1 \le m \le 2 \cdot 10^5$$$) — the number of vertices and edges of the graph, respectively. The next $$$m$$$ lines contain the description of the edges. Line $$$i$$$ contains three numbers $$$v_i$$$, $$$u_i$$$ and $$$w_i$$$ ($$$1 \le v_i, u_i \le n$$$, $$$1 \le w_i \le 10^9$$$, $$$v_i \neq u_i$$$) — the vertices that the edge connects and its weight. It is guaranteed that the sum $$$m$$$ and the sum $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$ and each test case contains a connected graph.

Print $$$t$$$ lines, each of which contains the answer to the corresponding set of input data — the minimum possible spanning tree ority.

Note  Graph from the first test case.   Ority of this tree equals to 2 or 2 = 2 and it's minimal.   Without excluding edge with weight $$$1$$$ ority is 1 or 2 = 3.

const readline = require('readline')

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

function solve(n, m, edges) {
    let or = Math.pow(2, 30) - 1
    for (let i = 29; i >= 0; i--) {
        const mask = 1 << i
        or -= mask
        const [p, r] = initDSU(n + 1)
        edges.forEach(([u, v, w], j) => {
            if ((or | w) === or) unite(u, v, p, r)
        })
        // console.log(p)
        let has = false
        for (let j = 1; j <= n; j++) {
            if (unite(1, j, p, r)) {
                has = true
                break
            }
        }
        // console.log(remove, has)
        if (has) {
            or += mask
        }
    }
    return or
}
function initDSU(n) {
    const p = Array(n) // parent
    for (let i = 0; i < n; i++) {
        p[i] = i
    }
    const r = Array(n).fill(1) // rank
    return [p, r]
}
function find(u, p) {
    if (p[u] !== u) {
        p[u] = find(p[u], p)
        return p[u]
    }
    return u
}
function unite(u, v, p, r) {
    u = find(u, p)
    v = find(v, p)
    if (u === v) return false

    if (r[u] < r[v]) [u, v] = [v, u]
    p[v] = u
    r[u] += r[v]
    return true
}

const readline = require('readline')

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

function solve(n, m, edges) {
    edges.sort((a, b) => b[2] - a[2])
// console.log(edges)
    const [p, r] = initDSU(n + 1)
    const ds = Array(n + 1).fill(0)
    edges.forEach(([u, v, w]) => {
        ds[u]++
        ds[v]++
    })
    let mask = 1 << 30
    let or = 0
    edges.some(([u, v, w], i) => {
        if (find(u, p) === find(v, p)) return false

        while (mask && !(mask & w)) mask >>= 1
// console.log(mask)
        if (!mask) return true
        if (ds[u] === 1 || ds[v] === 1) {
            unite(u, v, p, r)
            or |= mask
            mask >>= 1

            let j = i - 1
            while (j >= 0 && edges[j][2] === w) {
                unite(edges[j][0], edges[j][1], p, r)
                j--
            }
        }
        ds[u]--
        ds[v]--
        return false
    })
    return or
}
function initDSU(n) {
    const p = Array(n) // parent
    for (let i = 0; i < n; i++) {
        p[i] = i
    }
    const r = Array(n).fill(1) // rank
    return [p, r]
}
function find(u, p) {
    if (p[u] !== u) {
        p[u] = find(p[u], p)
        return p[u]
    }
    return u
}
function unite(u, v, p, r) {
    u = find(u, p)
    v = find(v, p)
    if (u === v) return false

    if (r[u] < r[v]) [u, v] = [v, u]
    p[v] = u
    r[u] += r[v]
    return true
}