The Rebel fleet is on the run. It consists of m ships currently gathered around a single planet. Just a few seconds ago, the vastly more powerful Empire fleet has appeared in the same solar system, and the Rebels will need to escape into hyperspace. In order to spread the fleet, the captain of each ship has independently come up with the coordinate to which that ship will jump. In the obsolete navigation system used by the Rebels, this coordinate is given as the value of an arithmetic expression of the form .To plan the future of the resistance movement, Princess Heidi needs to know, for each ship, how many ships are going to end up at the same coordinate after the jump. You are her only hope!

The first line of the input contains a single integer m (1 ≤ m ≤ 200 000) – the number of ships. The next m lines describe one jump coordinate each, given as an arithmetic expression. An expression has the form (a+b)/c. Namely, it consists of: an opening parenthesis (, a positive integer a of up to two decimal digits, a plus sign +, a positive integer b of up to two decimal digits, a closing parenthesis ), a slash /, and a positive integer c of up to two decimal digits.

Print a single line consisting of m space-separated integers. The i-th integer should be equal to the number of ships whose coordinate is equal to that of the i-th ship (including the i-th ship itself).

NoteIn the sample testcase, the second and the third ship will both end up at the coordinate 3.Note that this problem has only two versions – easy and hard.

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

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

// numberTheory.ts

// function gcd(a: number, b: number) {
//   if (b == 0) {
//     return a
//   }
//
//   return gcd(b, a % b)
// }
//
// function isPrime(x: number) {
//   return true
// }
//
// export { gcd, isPrime }

// import './array'
//
// import io from './io'
// import { gcd } from './numberTheory'
//
// function main() {
//   let [n] = io.nextNumbers()
//
//   let parse = (s: string) => {
//     s = s.replace("(", "").replace(")", "").replace("/", "+")
//
//     let [a, b, c] = s.split("+").map((x) => parseInt(x))
//
//     let g = gcd(a + b, c)
//
//     return `${(a + b) / g}/${c / g}`
//   }
//
//   let cnt: any = {}
//
//   let r: string[] = []
//
//   for (let i = 0; i < n; ++i) {
//     let s = io.readline()
//
//     let x = parse(s)
//
//     cnt[x] = cnt[x] + 1 || 1
//
//     r.push(x)
//   }
//
//   io.put(r.map((x) => cnt[x]).join(" "))
// }
//
// // io.runEachTest(main)
// io.runMain(main)

var test = readline().split(' ')[0];
var ara = [];
var obj = {};
while(test>0){
	var x = readline();
	var p = eval(x);
	p = Math.round(p*10000000000)/10000000000;
	if(obj.hasOwnProperty(p+"")){
		obj[p]+=1;
	}
	else{
		obj[p+""]= 1;
	}
	ara.push(p);
	test--;
}
var ans = "";
for(var i = 0 ; i<ara.length;i++){
	ans+= obj[ara[i]] +" ";
}
print(ans);

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

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

// import './array'
//
// import io from './io'
//
// function main() {
//   let [n] = io.nextNumbers()
//
//   let parse = (s: string) => {
//     s = s.replace("(", "").replace(")", "").replace("/", "+")
//
//     let [a, b, c] = s.split("+").map((x) => parseInt(x))
//
//     return Math.floor((a + b) / c)
//   }
//
//   let cnt: any = {}
//
//   let r: number[] = []
//
//   for (let i = 0; i < n; ++i) {
//     let s = io.readline()
//
//     let x = parse(s)
//
//     cnt[x] = cnt[x] + 1 || 1
//
//     r.push(x)
//   }
//
//   io.put(r.map((x) => cnt[x]).join(" "))
// }
//
// // io.runEachTest(main)
// io.runMain(main)


NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:  It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.He managed to calculate the number of outer circles $$$n$$$ and the radius of the inner circle $$$r$$$. NN thinks that, using this information, you can exactly determine the radius of the outer circles $$$R$$$ so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that. Help NN find the required radius for building the required picture.

The first and the only line of the input file contains two numbers $$$n$$$ and $$$r$$$ ($$$3 \leq n \leq 100$$$, $$$1 \leq r \leq 100$$$) — the number of the outer circles and the radius of the inner circle respectively.

Output a single number $$$R$$$ — the radius of the outer circle required for building the required picture.  Your answer will be accepted if its relative or absolute error does not exceed $$$10^{-6}$$$. Formally, if your answer is $$$a$$$ and the jury's answer is $$$b$$$. Your answer is accepted if and only when $$$\frac{|a-b|}{max(1, |b|)} \le 10^{-6}$$$.

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

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

function main() {
  const [n, R] = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  const theta = Math.PI / n;
  const sinTheta = parseFloat(Math.sin(theta));
  const r = (R * sinTheta) / (1 - sinTheta);

  console.log(r.toFixed(7));
}

function calc(n, r) {
  if (n === 6) {
    return r;
  } else {
    sinAlpha = Math.sin(Math.PI / n);
    return r * sinAlpha / (1 - sinAlpha);
  }
}

var nr = readline().split(" ");
var n = parseInt(nr[0]);
var r = parseInt(nr[1]);

print(calc(n, r));


We all know the problem about the number of ways one can tile a 2 × n field by 1 × 2 dominoes. You probably remember that it goes down to Fibonacci numbers. We will talk about some other problem below, there you also are going to deal with tiling a rectangular field with dominoes.You are given a 4 × n rectangular field, that is the field that contains four lines and n columns. You have to find for it any tiling by 1 × 2 dominoes such that each of the n - 1 potential vertical cuts along the grid lines intersects at least one domino, splitting it in two. No two dominoes in the sought tiling should overlap, each square of the field should be covered by exactly one domino. It is allowed to rotate the dominoes, that is, you can use 2 × 1 as well as 1 × 2 dominoes.Write a program that finds an arbitrary sought tiling.

The input contains one positive integer n (1 ≤ n ≤ 100) — the number of the field's columns.

If there's no solution, print "-1" (without the quotes). Otherwise, print four lines containing n characters each — that's the description of tiling, where each vertical cut intersects at least one domino. You should print the tiling, having painted the field in no more than 26 colors. Each domino should be painted a color. Different dominoes can be painted the same color, but dominoes of the same color should not be side-neighbouring. To indicate colors you should use lowercase Latin letters. Print any of the acceptable ways of tiling.


You are given a non-decreasing array of non-negative integers $$$a_1, a_2, \ldots, a_n$$$. Also you are given a positive integer $$$k$$$.You want to find $$$m$$$ non-decreasing arrays of non-negative integers $$$b_1, b_2, \ldots, b_m$$$, such that:  The size of $$$b_i$$$ is equal to $$$n$$$ for all $$$1 \leq i \leq m$$$.  For all $$$1 \leq j \leq n$$$, $$$a_j = b_{1, j} + b_{2, j} + \ldots + b_{m, j}$$$. In the other word, array $$$a$$$ is the sum of arrays $$$b_i$$$.  The number of different elements in the array $$$b_i$$$ is at most $$$k$$$ for all $$$1 \leq i \leq m$$$. Find the minimum possible value of $$$m$$$, or report that there is no possible $$$m$$$.

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The first line of each test case contains two integers $$$n$$$, $$$k$$$ ($$$1 \leq n \leq 100$$$, $$$1 \leq k \leq n$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \leq a_1 \leq a_2 \leq \ldots \leq a_n \leq 100$$$, $$$a_n > 0$$$).

For each test case print a single integer: the minimum possible value of $$$m$$$. If there is no such $$$m$$$, print $$$-1$$$.

NoteIn the first test case, there is no possible $$$m$$$, because all elements of all arrays should be equal to $$$0$$$. But in this case, it is impossible to get $$$a_4 = 1$$$ as the sum of zeros.In the second test case, we can take $$$b_1 = [3, 3, 3]$$$. $$$1$$$ is the smallest possible value of $$$m$$$.In the third test case, we can take $$$b_1 = [0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]$$$ and $$$b_2 = [0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2]$$$. It's easy to see, that $$$a_i = b_{1, i} + b_{2, i}$$$ for all $$$i$$$ and the number of different elements in $$$b_1$$$ and in $$$b_2$$$ is equal to $$$3$$$ (so it is at most $$$3$$$). It can be proven that $$$2$$$ is the smallest possible value of $$$m$$$.

function solv() {
    var ip = readline().split(' ').map(x => parseInt(x));
    var x = ip[0]
    var y = ip[1]
    var s = readline().split(' ').map(x => parseInt(x))

    var v = {}
    for (var n = 0; n < x; n++)v[s[n]] = 1
    s = []
    for (n in v) s.push(n);
    if (s.length > 1 && y == 1) {
        print(-1);
        return;
    }
    var res = 1;
    var cur = 0;
    v = {};
    for (var n = 0; n < s.length; n++) {
        v[s[n]] = 1;
        if (Object.keys(v).length == y && n < s.length - 1) {
            res++;
            v = {};
            v[s[n]] = 1;
        }
    }
    print(res);
}
var t = parseInt(readline());
while (t--)
    solv()

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

function Arr(a, b, fn, init) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b, fn);
  if (b < a) return [];
  let arr = Array(b - a + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i++) 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 ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

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

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
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 t = $()
  while (t--) {
    let [n, k] = $(2)
    let a = $(n).uniq()
    // log(a)
    if (k == 1) {
      if (a.length == 1) log(1);
      else log(-1)
    } else {
      log(For(1, 100, i => Math.ceil((a.length - 1) / i + 1) <= k ? i : null))
    }
  }
}

#!/usr/bin/env node
'use strict';

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

const buf = [];
const prom = [];
let maxBuf = 0;
let maxProm = 0;
rl.on('line', (line) => {
  if (prom.length > 0) {
    maxProm = Math.max(maxProm, prom.length);
    const [resolve, reject] = prom.shift();
    resolve(line);
  } else {
    rl.pause();
    buf.push(line);
    maxBuf = Math.max(maxBuf, buf.length);
  }
});

rl.on('close', () => {
  // console.error({maxProm, maxBuf});
});

async function getLine() {
  return new Promise((resolve, reject) => {
    if (buf.length > 0) {
      const line = buf.shift();
      resolve(line);
    } else {
      prom.push([resolve, reject]);
      rl.resume();
    }
  });
}

/**
 *
 * @param {Number []} a
 * @param {Number} k
 * @returns {Number []}
 */
function solve(a, k) {
  if (k < 1) {
    return -1;
  }
  const n = a.length;
  if (n < 1) {
    return -1;
  }
  const kinds = new Set();
  for (const ai of a) {
    kinds.add(ai);
  }
  const m = kinds.size;
  if (k === 1) {
    return (m !== 1) ? -1 : 1;
  }

  return (m === 1) ? 1 : Math.ceil((m - 1) / (k - 1));
}

async function main() {
  const t = Number(await getLine());
  for (let i = 0; i < t; i++) {
    const [n, k] = (await getLine()).split(' ').map(Number);
    const a = (await getLine()).split(' ').map(Number);
    const res = solve(a, k);
    console.log(res);
  }
}

if (require.main === module) {
  main();
}

function solv() {
    var ip = readline().split(' ').map(x => parseInt(x));
    var x = ip[0]
    var y = ip[1]
    var s = readline().split(' ').map(x => parseInt(x))

    var v = {}
    for (var n = 0; n < x; n++)v[s[n]] = 1
    s = []
    for (n in v) s.push(n);
    if (s.length > 1 && y == 1) {
        print(-1);
        return;
    }
    var res = 1;
    var cur = 0;
    v = {};
    for (n in s) {
        v[n] = 1;
        if (Object.keys(v).length > y) {
            res++;
            v = {};
        }
    }
    print(res);
}
var t = parseInt(readline());
while (t--)
    solv()

function solv() {
    var ip = readline().split(' ').map(x => parseInt(x));
    var x = ip[0]
    var y = ip[1]
    var s = readline().split(' ').map(x => parseInt(x))

    var v = {}
    for (var n = 0; n < x; n++)v[s[n]] = 1
    s = []
    for (n in v) s.push(n);
    if (s.length > 1 && y == 1) {
        print(-1);
        return;
    }
    var res = 1;
    var cur = 0;
    v = {};
    for (n in s) {
        v[n] = 1;
        if (Object.keys(v).length > y) {
            res++;
            v = {};
            v[n] = 1;
        }
    }
    print(res);
}
var t = parseInt(readline());
while (t--)
    solv()


You are given a rooted tree. It contains $$$n$$$ vertices, which are numbered from $$$1$$$ to $$$n$$$. The root is the vertex $$$1$$$.Each edge has two positive integer values. Thus, two positive integers $$$a_j$$$ and $$$b_j$$$ are given for each edge.Output $$$n-1$$$ numbers $$$r_2, r_3, \dots, r_n$$$, where $$$r_i$$$ is defined as follows.Consider the path from the root (vertex $$$1$$$) to $$$i$$$ ($$$2 \le i \le n$$$). Let the sum of the costs of $$$a_j$$$ along this path be $$$A_i$$$. Then $$$r_i$$$ is equal to the length of the maximum prefix of this path such that the sum of $$$b_j$$$ along this prefix does not exceed $$$A_i$$$.    Example for $$$n=9$$$. The blue color shows the costs of $$$a_j$$$, and the red color shows the costs of $$$b_j$$$. Consider an example. In this case:  $$$r_2=0$$$, since the path to $$$2$$$ has an amount of $$$a_j$$$ equal to $$$5$$$, only the prefix of this path of length $$$0$$$ has a smaller or equal amount of $$$b_j$$$; $$$r_3=3$$$, since the path to $$$3$$$ has an amount of $$$a_j$$$ equal to $$$5+9+5=19$$$, the prefix of length $$$3$$$ of this path has a sum of $$$b_j$$$ equal to $$$6+10+1=17$$$ ( the number is $$$17 \le 19$$$); $$$r_4=1$$$, since the path to $$$4$$$ has an amount of $$$a_j$$$ equal to $$$5+9=14$$$, the prefix of length $$$1$$$ of this path has an amount of $$$b_j$$$ equal to $$$6$$$ (this is the longest suitable prefix, since the prefix of length $$$2$$$ already has an amount of $$$b_j$$$ equal to $$$6+10=16$$$, which is more than $$$14$$$); $$$r_5=2$$$, since the path to $$$5$$$ has an amount of $$$a_j$$$ equal to $$$5+9+2=16$$$, the prefix of length $$$2$$$ of this path has a sum of $$$b_j$$$ equal to $$$6+10=16$$$ (this is the longest suitable prefix, since the prefix of length $$$3$$$ already has an amount of $$$b_j$$$ equal to $$$6+10+1=17$$$, what is more than $$$16$$$); $$$r_6=1$$$, since the path up to $$$6$$$ has an amount of $$$a_j$$$ equal to $$$2$$$, the prefix of length $$$1$$$ of this path has an amount of $$$b_j$$$ equal to $$$1$$$; $$$r_7=1$$$, since the path to $$$7$$$ has an amount of $$$a_j$$$ equal to $$$5+3=8$$$, the prefix of length $$$1$$$ of this path has an amount of $$$b_j$$$ equal to $$$6$$$ (this is the longest suitable prefix, since the prefix of length $$$2$$$ already has an amount of $$$b_j$$$ equal to $$$6+3=9$$$, which is more than $$$8$$$); $$$r_8=2$$$, since the path up to $$$8$$$ has an amount of $$$a_j$$$ equal to $$$2+4=6$$$, the prefix of length $$$2$$$ of this path has an amount of $$$b_j$$$ equal to $$$1+3=4$$$; $$$r_9=3$$$, since the path to $$$9$$$ has an amount of $$$a_j$$$ equal to $$$2+4+1=7$$$, the prefix of length $$$3$$$ of this path has a sum of $$$b_j$$$ equal to $$$1+3+3=7$$$.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the test. The descriptions of test cases follow. Each description begins with a line that contains an integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) — the number of vertices in the tree. This is followed by $$$n-1$$$ string, each of which contains three numbers $$$p_j, a_j, b_j$$$ ($$$1 \le p_j \le n$$$; $$$1 \le a_j,b_j \le 10^9$$$) — the ancestor of the vertex $$$j$$$, the first and second values an edge that leads from $$$p_j$$$ to $$$j$$$. The value of $$$j$$$ runs through all values from $$$2$$$ to $$$n$$$ inclusive. It is guaranteed that each set of input data has a correct hanged tree with a root at the vertex $$$1$$$. It is guaranteed that the sum of $$$n$$$ over all input test cases does not exceed $$$2\cdot10^5$$$.

For each test case, output $$$n-1$$$ integer in one line: $$$r_2, r_3, \dots, r_n$$$.

NoteThe first example is clarified in the statement.In the second example:  $$$r_2=0$$$, since the path to $$$2$$$ has an amount of $$$a_j$$$ equal to $$$1$$$, only the prefix of this path of length $$$0$$$ has a smaller or equal amount of $$$b_j$$$; $$$r_3=0$$$, since the path to $$$3$$$ has an amount of $$$a_j$$$ equal to $$$1+1=2$$$, the prefix of length $$$1$$$ of this path has an amount of $$$b_j$$$ equal to $$$100$$$ ($$$100 > 2$$$); $$$r_4=3$$$, since the path to $$$4$$$ has an amount of $$$a_j$$$ equal to $$$1+1+101=103$$$, the prefix of length $$$3$$$ of this path has an amount of $$$b_j$$$ equal to $$$102$$$, .

'use strict';

function solve(n, a) {
  const h = new Array(n).fill(-1),
        te = [],
        ne = [],
        d = new Array(n).fill(0),
        b = [],
        c = [];
  const add = (i, j, x, y) => {
    b.push(x), c.push(y), te.push(j), ne.push(h[i]), h[i] = ne.length - 1, d[j]++;
  };
  for (let [i, [p, x, y]] of a.entries()) {
    add(p - 1, i + 1, x, y);
  }
  const res = [],
        pre = [0];
  const dfs = RTI((u, w, p = -1, sum = 0) => {
    if (p !== -1) {
      pre.push(pre[pre.length - 1] + w);
      let l = 0,
          r = pre.length - 1;
      while (l < r) {
        const m = l + r + 1 >> 1;
        if (pre[m] <= sum) {
          l = m;
        } else {
          r = m - 1;
        }
      }
      res[u - 1] = l;
    }
    const inside = () => {
      let res = [];
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = te[i];
        if (p === v) continue;
        sum += b[i];
        res.push([v, c[i], u, sum]);
        sum -= b[i];
      }
      return res;
    };
    const after = (args, childResult) => {
      pre.pop();
    };
    return [inside, after];
  });
  dfs(0);
  return res.join(' ');
}
function RTI(fn) {
  let res;
  const createNode = args => {
    return {
      args,
      result: [],
      curIndex: 0
    };
  };
  const dfs = (...args) => {
    const root = createNode([args]);
    root.cb = ([args], [result]) => res = result;
    const callStack = [root];
    while (callStack.length) {
      let curCall = callStack[callStack.length - 1];
      while (curCall && curCall.args.length === curCall.curIndex) {
        var _curCall$cb, _curCall;
        const res = (_curCall$cb = (_curCall = curCall).cb) === null || _curCall$cb === void 0 ? void 0 : _curCall$cb.call(_curCall, curCall.args, curCall.result);
        callStack.pop();
        curCall = callStack[callStack.length - 1];
        if (curCall) curCall.result[curCall.curIndex++] = res;
      }
      if (!curCall) break;
      const {
        args,
        curIndex
      } = curCall;
      {
        const res = fn(...args[curIndex]);
        const [inside, after] = res;
        let nextCall = inside();
        const node = createNode(nextCall);
        node.cb = after;
        callStack.push(node);
      }
    }
    return res;
  };
  return dfs;
}

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

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

const readline = require('readline')

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

class Queue {
    constructor() {
        this.map = {}
        this.first = 0
        this.last = 0
    }
    push(...args) {
        for (let i = 0; i < args.length; i++) {
            this.map[this.last++] = args[i]
        }
    }
    pop() {
        const r = this.map[this.last]
        delete this.map[this.last]
        this.last--
        return r
    }
    shift() {
        const r = this.map[this.first]
        delete this.map[this.first]
        this.first++
        return r
    }
    get length() {
        if (this.first >= this.last) return 0
        return this.last - this.first
    }
    get(x) {
        return this.map[x]
    }
    getLast() {
        return this.map[this.last - 1]
    }
}

function solve(n, edges) {
    const adj = {}
    const es = Array(n + 1)
    edges.forEach(([p, va, vb], i) => {
        let a = i + 2
        let b = p
        adj[a] = adj[a] || []
        adj[b] = adj[b] || []
        adj[a].push(b)
        adj[b].push(a)
        es[a] = [va, vb]
    })
    return dfs(adj, 1, n, es).join(' ')
}
function dfs(adj, r, n, es) {
    // const stack = [[r, 0, -1]]
    const stack = new Queue()
    stack.push([r, 0, -1])
    const rs = Array(n).fill(0)
    // const sa = new Queue()
    // sa.push(0)
    let sa = 0
    const sb = new Queue()
    sb.push(0)
    while (stack.length) {
        const [u, i, p] = stack.getLast()
        // visited[u] = 1

        const nb = adj[u] || []
        if (!i) {
            // first visited
            if (p >= 0) {
                sa += es[u][0]
                // sb += es[u][1]
                sb.push(sb.getLast() + es[u][1])
                rs[u] = binarySearch(0, sb.length - 1, x => {
                    return sb.get(x) <= sa
                })
            }
        }
        if (i < nb.length) {
            stack.getLast()[1]++
            const v = nb[i]
            // if (!visited[v]) { // has circle
            if (v !== p) {
                stack.push([v, 0, u])
            }
        } else {
            // last visited
            stack.pop()
            if (p >= 0) {
                sa -= es[u][0]
                // sb -= es[u][1]
                sb.pop()
            }
        }
    }
    rs.shift()
    rs.shift()
    return rs
}
function binarySearch(l, r, fn) {
    while (l <= r) {
        const m = Math.floor((l + r) / 2)
        if (fn(m)) {
            l = m + 1
        } else {
            r = m - 1
        }
    }
    return r
}


Petya works as a PR manager for a successful Berland company BerSoft. He needs to prepare a presentation on the company income growth since 2001 (the year of its founding) till now. Petya knows that in 2001 the company income amounted to a1 billion bourles, in 2002 — to a2 billion, ..., and in the current (2000 + n)-th year — an billion bourles. On the base of the information Petya decided to show in his presentation the linear progress history which is in his opinion perfect. According to a graph Petya has already made, in the first year BerSoft company income must amount to 1 billion bourles, in the second year — 2 billion bourles etc., each following year the income increases by 1 billion bourles. Unfortunately, the real numbers are different from the perfect ones. Among the numbers ai can even occur negative ones that are a sign of the company’s losses in some years. That is why Petya wants to ignore some data, in other words, cross some numbers ai from the sequence and leave only some subsequence that has perfect growth.Thus Petya has to choose a sequence of years y1, y2, ..., yk,so that in the year y1 the company income amounted to 1 billion bourles, in the year y2 — 2 billion bourles etc., in accordance with the perfect growth dynamics. Help him to choose the longest such sequence.

The first line contains an integer n (1 ≤ n ≤ 100). The next line contains n integers ai ( - 100 ≤ ai ≤ 100). The number ai determines the income of BerSoft company in the (2000 + i)-th year. The numbers in the line are separated by spaces.

Output k — the maximum possible length of a perfect sequence. In the next line output the sequence of years y1, y2, ..., yk. Separate the numbers by spaces. If the answer is not unique, output any. If no solution exist, output one number 0.

const readline = require('readline');

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

var n, indicator=0;
rl.on('line', (input) => {
    if(indicator==0){
        n=parseInt(input);
        indicator++;
    }
    else{
        let cont=input.split(" ").map(item=>parseInt(item));
        let  ans=[];
        for(let i=0,year=2001,temp=1;i<cont.length;i++,year++){
            if(cont[i]==temp){
                ans.push(year);
                temp++;

            }

        }
      console.log(ans.length);
      /*
      for(let i=0; i<ans.length;i++){
          rl.write(ans[i]+" ");
      }*/
      /*
      ans.forEach(item=>{
          rl.write(item+" ");
      });
      */
     console.log(ans.join(" "));
      rl.close();

    }
  });

'use strict'

let N = +readline()
let lll = readline().split(' ').map(v => parseInt(v))

let res = []
let c = 1
for (let i = 0; i < N; i++) {
  if (lll[i] == c) {c++; res.push(i + 2001)}
}

print(res.length)
if (res.length) print(res.join(' '))

var n = parseInt(readline());
var input = readline().split(' ').map(function (a) {return parseInt(a)});
var curr_value = 1;
var curr_year = 2001;
var years = [];
var num = 0;

for (var i = 0; i < n; i++) {
	if (input[i] == curr_value) {
		years.push(curr_year);
		num++;
		curr_value++;
	}
	curr_year++;
}

if (num === 0) {
	print(0);
} else {
	print(num);
	print(years.join(' '));
}

const readline = require('readline');

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

var n, indicator=0;
rl.on('line', (input) => {
    if(indicator==0){
        n=parseInt(input);
        indicator++;
    }
    else{
        let cont=input.split(" ").map(item=>parseInt(item));
        let  ans=[];
        for(let i=0,year=2001,temp=1;i<cont.length;i++,year++){
            if(cont[i]==temp){
                ans.push(year);
                temp++;

            }

        }
      console.log(ans.length);

      ans.forEach(item=>{
          rl.write(item+" ");
      });
      rl.close();

    }
  });

const readline = require('readline');

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

var n, indicator=0;
rl.on('line', (input) => {
    if(indicator==0){
        n=parseInt(input);
        indicator++;
    }
    else{
        let cont=input.split(" ").map(item=>parseInt(item));
        let  ans=[];
        for(let i=0,year=2001,temp=1;i<cont.length;i++,year++){
            if(cont[i]==temp){
                ans.push(year);
                temp++;

            }

        }
      console.log(ans.length);
      /*
      for(let i=0; i<ans.length;i++){
          rl.write(ans[i]+" ");
      }*/
      ans.forEach(item=>{
          rl.write(item+" ");
      });
      rl.close();

    }
  });


A tourist hiked along the mountain range. The hike lasted for n days, during each day the tourist noted height above the sea level. On the i-th day height was equal to some integer hi. The tourist pick smooth enough route for his hike, meaning that the between any two consecutive days height changes by at most 1, i.e. for all i's from 1 to n - 1 the inequality |hi - hi + 1| ≤ 1 holds.At the end of the route the tourist rafted down a mountain river and some notes in the journal were washed away. Moreover, the numbers in the notes could have been distorted. Now the tourist wonders what could be the maximum height during his hike. Help him restore the maximum possible value of the maximum height throughout the hike or determine that the notes were so much distorted that they do not represent any possible height values that meet limits |hi - hi + 1| ≤ 1.

The first line contains two space-separated numbers, n and m (1 ≤ n ≤ 108, 1 ≤ m ≤ 105) — the number of days of the hike and the number of notes left in the journal. Next m lines contain two space-separated integers di and hdi (1 ≤ di ≤ n, 0 ≤ hdi ≤ 108) — the number of the day when the i-th note was made and height on the di-th day. It is guaranteed that the notes are given in the chronological order, i.e. for all i from 1 to m - 1 the following condition holds: di < di + 1.

If the notes aren't contradictory, print a single integer — the maximum possible height value throughout the whole route. If the notes do not correspond to any set of heights, print a single word 'IMPOSSIBLE' (without the quotes).

NoteFor the first sample, an example of a correct height sequence with a maximum of 2: (0, 0, 1, 2, 1, 1, 0, 1).In the second sample the inequality between h7 and h8 does not hold, thus the information is inconsistent.

function isOk (a0,a1){
  var i0=a0[0];
  var h0=a0[1];
  var i1=a1[0];
  var h1=a1[1];
  if (h1 < h0){
    return isOk([i0,h1],[i1,h0]);
  }else{
    return (i1-i0) >= (h1-h0);
  }
}
function getMaxHeight (a0,a1){
  var i0=a0[0];
  var h0=a0[1];
  var i1=a1[0];
  var h1=a1[1];
  var d=h1-h0;
  var s=i1-i0;
  if (h1 < h0){
    return getMaxHeight ([i0,h1],[i1,h0]);
  }else if (h0<h1){
    return getMaxHeight ([i0+d,h0+d],[i1,h1]);
  }else{
    return h0+((s-s%2)/2);
  }
}
function getMax1Height (a){
  var i0=a[0];
  var h0=a[1];
  return h0+i0-1;
}
function getMaxNHeight (n,a){
  var i0=a[0];
  var h0=a[1];
  return h0+(n-i0);
}
function to_i(x){
  return parseInt(x);
}
var s = readline();
var hlist=[];
var t = s.split(" ").map(to_i);
var n=t[0];
var m=t[1];
for(var i=0;i<m;i++){
  var s=readline();
  var t=s.split(" ").map(to_i);
  hlist.push(t);
}
var iscan=true;
for(var i=1;i<m;i++){
  if (!isOk(hlist[i-1],hlist[i])){
    iscan=false;
    break;
  }
}
if(iscan==false){
  print("IMPOSSIBLE");
}else{
  var res = getMax1Height(hlist[0]);
  res = Math.max(res,getMaxNHeight(n,hlist[m-1]));
  for(i=1;i<m;i++){
    res=Math.max(res,getMaxHeight(hlist[i-1],hlist[i]));
  }
  print(res);
}


Theofanis really likes sequences of positive integers, thus his teacher (Yeltsa Kcir) gave him a problem about a sequence that consists of only special numbers.Let's call a positive number special if it can be written as a sum of different non-negative powers of $$$n$$$. For example, for $$$n = 4$$$ number $$$17$$$ is special, because it can be written as $$$4^0 + 4^2 = 1 + 16 = 17$$$, but $$$9$$$ is not.Theofanis asks you to help him find the $$$k$$$-th special number if they are sorted in increasing order. Since this number may be too large, output it modulo $$$10^9+7$$$.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The first and only line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$; $$$1 \le k \le 10^9$$$).

For each test case, print one integer — the $$$k$$$-th special number in increasing order modulo $$$10^9+7$$$.

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

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

let count = -1
let inputArr = []

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

function sumS(n, count) {
    let res = 1n
    for (let j = 0n; j < count; ++j) res = (res * n) % 1000000007n
    return res
}

function solve([n, k]) {
    let dbl, sum = 0n, counter = 0n
    while ((2n ** counter) <= k) {
        dbl = (k >> counter) & 1n
        if (dbl) sum = (sum + sumS(n, counter)) % 1000000007n
        counter++
    }
    console.log(sum.toString())
}

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

let mod = BigInt(10e8+7);
const solve = (n,k)=>{
     let n1 = k,cnt = 1n,res = 0n;
     while(n1){
          if(n1&1n){
               res = (res + cnt)%mod;
          }
          n1 = n1>>1n;
          cnt = (cnt*n)%mod;
     }
     console.log(res+"");
}
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,k] = readline().trim().split(" ").map(cur=>BigInt(cur));
       solve(n,k);
  }
}
main();

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++]
    for (let i = 0; i < t; i++) {
        const [n, k] = lines[l++].trim().split(' ').map(Number)
        console.log(solve(n, k))
    }
// })()
})

function solve(n, k) {
    const str = k.toString(2)
    let base = 1
    let sum = 0
    for (let i = str.length - 1; i >= 0; i--) {
        if (str[i] === '1') {
            sum = add(sum, base)
        }
        base = mul(base, n)
    }
    return sum
}
function add(a, b) {
    return (a + b) % (1e9 + 7)
}
function mul(a, b) {
    let r = 0
    let base = a
    while (b) {
        if (b & 1) {
            r = add(r, base)
        }
        b >>= 1
        base = add(base, base)
    }
    return r
}

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

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

let count = -1
let inputArr = []

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

function sumS(n, count) {
    let res = 1
    for (let j = 0; j < count; ++j) res = (res * n) % 1000000007
    return res
}

function solve([n, k]) {
    let dbl, sum = 0, counter = 0
    while ((2 ** counter) <= k) {
        dbl = (k >> counter) & 1
        if (dbl) sum = (sum + sumS(n, counter)) % 1000000007
        counter++
    }
    console.log(sum)
}

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


Spring has come, and the management of the AvtoBus bus fleet has given the order to replace winter tires with summer tires on all buses.You own a small bus service business and you have just received an order to replace $$$n$$$ tires. You know that the bus fleet owns two types of buses: with two axles (these buses have $$$4$$$ wheels) and with three axles (these buses have $$$6$$$ wheels).You don't know how many buses of which type the AvtoBus bus fleet owns, so you wonder how many buses the fleet might have. You have to determine the minimum and the maximum number of buses that can be in the fleet if you know that the total number of wheels for all buses is $$$n$$$.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 1\,000$$$) — the number of test cases. The following lines contain description of test cases. The only line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 10^{18}$$$) — the total number of wheels for all buses.

For each test case print the answer in a single line using the following format. Print two integers $$$x$$$ and $$$y$$$ ($$$1 \le x \le y$$$) — the minimum and the maximum possible number of buses that can be in the bus fleet. If there is no suitable number of buses for the given $$$n$$$, print the number $$$-1$$$ as the answer.

NoteIn the first test case the total number of wheels is $$$4$$$. It means that there is the only one bus with two axles in the bus fleet.In the second test case it's easy to show that there is no suitable number of buses with $$$7$$$ wheels in total.In the third test case the total number of wheels is $$$24$$$. The following options are possible:  Four buses with three axles.  Three buses with two axles and two buses with three axles.  Six buses with two axles. So the minimum number of buses is $$$4$$$ and the maximum number of buses is $$$6$$$.

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

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

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

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

function main() {
var testCase = parseInt(readline());

function division(n, divisor) {
    var remainder;
    var dividend = n[0];
    var quotient = [];

    for (let i = 0; i < n.length; i++) {
        if (dividend < divisor) {
            quotient.push(Math.floor(dividend / divisor));
            remainder = dividend;
            dividend = (remainder * 10) + n[i + 1];
        } else {
            quotient.push(Math.floor(dividend / divisor));
            remainder = dividend % divisor;
            dividend = (remainder * 10) + n[i + 1];
        }
    }

    if (quotient[0] === 0) {
        quotient.shift();
    }
    if (divisor === 6 && remainder > 0) {
        if (quotient.length < 2) {
            return Number(quotient.join("")) + 1;
        }
        var carry = 1;
        var total =[];
        var sum;
        for (let j = quotient.length -1 ; j >= 0; j--) {
            sum = quotient[j] + carry;
            if (sum > 9 && j!==0) {
                total.unshift(0);
            } else {
                total.unshift(sum);
                carry = 0;
            }
        }
        return total.join("");
    }
    return quotient.join("");
}

for (let i = 0; i < testCase; i++) {
    var n = readline().trim().split('').map(Number);
    var result;
    var sum = 0;
    for (let i = 0; i < n.length; i++) {
        sum += n[i];
    }
    var divisiblebyfour = n.length < 2 ? n[n.length - 1] : ((n[n.length - 2] * 10) + n[n.length - 1]);
    if (n[n.length - 1] % 2 !== 0) {
        console.log(-1);
    } else if (n.length < 2 && n[n.length - 1] < 4) {
        console.log(-1);
    } else {
        console.log(division(n, 6), division(n, 4));
    }
}
}

const solve = (str)=>{
     let n = BigInt(str);
     let min = 6n;
     let max = 4n;
     if((n%2n===1n)||(n<3n)) return -1;
     let r1 = n%min,r2 = n%max;
     r1 = r1>0n ? (n/min)+1n : n/min;
     r2 = n/max;
     return `${r1} ${r2}`;
}
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();
       console.log(solve(n));
  }
}
main();

const readline = require('readline')

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

function solve(n) {
    if (n < 4n) return -1
    if (n & 1n) return -1
    const a = n / 4n
    const b = ceil(n, 6n)
    return b + ' ' + a
}
function ceil(a, b) {
    const r = a % b
    const f = a / b
    return r ? f + 1n : f
}

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

let lines = 0;
const maxBuses = (n) => {
  switch (n % 4n) {
    case 0n:
      return n / 4n;
    case 1n:
      return -1;
    case 2n:
      return n > 4n ? (n - 4n) / 4n + 1n : -1;
    case 3n:
      return -1;
  }
};
const minBuses = (n) => {
  switch (n % 6n) {
    case 0n:
      return n / 6n;
    case 1n:
      return -1;
    case 2n:
      return n > 6n ? (n - 6n) / 6n + 2n : -1;
    case 3n:
      return -1;
    case 4n:
      return n > 6n ? n / 6n + 1n : -1;
    case 5n:
      return -1;
  }
};

rl.on("line", function (line) {
  if (lines !== 0) {
    const input = BigInt(line);
    const min = minBuses(input);
    const max = maxBuses(input);
    if (min === -1 && max === -1) {
      return console.log("-1");
    } else if (min === -1 || max === -1) {
      const [common] = [min, max]
        .filter((x) => x !== -1)
        .map((x) => x.toString());
      return console.log(common, common);
    }
    console.log(min.toString(), max.toString());
  }
  lines++;
});

'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) {
  if (n % 2n !== 0n || n < 4n) return '-1';
  let min = 0n,
      max = 0n;
  for (let i = 0n; i < n; i++) {
    if ((n - 4n * i) % 6n === 0n) {
      min = i + (n - 4n * i) / 6n;
      break;
    }
  }
  for (let i = 0n; i < n; i++) {
    if ((n - 6n * i) % 4n === 0n) {
      max = i + (n - 6n * i) / 4n;
      break;
    }
  }
  return `${min.toString()} ${max.toString()}`;
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const n = BigInt(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);
}();

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

let ls = [];

function solve() {
    let l = 0;
    let t = parseInt(ls[l++]);
    for (; t > 0; t--){
        const n = BigInt(ls[l++]);
        if (n % 2n == 1 || n < 4n){
            console.log(-1);
            continue;
        }

        let x = n % 6n == 0 ? n / 6n : n / 6n + 1n;
        let y = n / 4n;
        console.log(`${x} ${y}`);
    }
}

rl.on('line', (l) => ls.push(l));
rl.on('close', () => solve());

'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 = [
`1 1`, // Test #1
`-1`, // Test #2
`4 6`, // Test #3
`166374058999707392 249561088499561088`, // Test #4
``, // Test #5
];

// SOLUTION:
IS_MULTITEST = true;

const calc = (testN)=>{
  // READING:
  let n = readline();
  n = BigInt(n);
  LT({n});
  // PROCESSING:
  if (n % 2n != 0n){
    return -1;
  }
  n = n / 2n;
  let min, max;
  for (let x = 0n; x<=5n; x++){
    let m = n - x*2n;
    if (m>=0 && m%3n==0){
      min = x + m/3n;
      break;
    }
  }
  if (!min)
    return -1;
  for (let y = 0n; y<=5n; y++){
    let m = n - y*3n;
    if (m>=0 && m%2n==0){
      max = y + m/2n;
      break;
    }
  }
  if (!max)
    return -1;
  return [min.toString(), max.toString()]
};

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

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

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

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

function main() {
var testCase = parseInt(readline());

function division(n, divisor) {
    var remainder;
    var dividend = n[0];
    var quotient = [];

    for (let i = 0; i < n.length; i++) {
        if (dividend < divisor) {
            quotient.push(Math.floor(dividend / divisor));
            remainder = dividend;
            dividend = (remainder * 10) + n[i + 1];
        } else {
            quotient.push(Math.floor(dividend / divisor));
            remainder = dividend % divisor;
            dividend = (remainder * 10) + n[i + 1];
        }
    }

    if (quotient[0] === 0) {
        quotient.shift();
    }
    if (divisor === 6 && remainder > 0) {
        if (quotient.length < 2) {
            return 1;
        }
        var carry = 1;
        var total =[];
        var sum;
        for (let j = quotient.length -1 ; j >= 0; j--) {
            sum = quotient[j] + carry;
            if (sum > 9 && j!==0) {
                total.unshift(0);
            } else {
                total.unshift(sum);
                carry = 0;
            }
        }
        return total.join("");
    }
    return quotient.join("");
}

for (let i = 0; i < testCase; i++) {
    var n = readline().trim().split('').map(Number);
    var result;
    var sum = 0;
    for (let i = 0; i < n.length; i++) {
        sum += n[i];
    }
    var divisiblebyfour = n.length < 2 ? n[n.length - 1] : ((n[n.length - 2] * 10) + n[n.length - 1]);
    if (n[n.length - 1] % 2 !== 0) {
        console.log(-1);
    } else if (n.length < 2 && n[n.length - 1] < 4) {
        console.log(-1);
    } else {
        console.log(division(n, 6), division(n, 4));
    }
}
}

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

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

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

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

function main() {
var testCase = parseInt(readline());

function division(n, divisor) {
    var remainder;
    var dividend = n[0];
    var quotient = [];

    for (let i = 0; i < n.length; i++) {
        if (dividend < divisor) {
            quotient.push(Math.floor(dividend / divisor));
            remainder = dividend;
            dividend = (remainder * 10) + n[i + 1];
        } else {
            quotient.push(Math.floor(dividend / divisor));
            remainder = dividend % divisor;
            dividend = (remainder * 10) + n[i + 1];
        }
    }

    if (quotient[0] === 0) {
        quotient.shift();
    }
    if (divisor === 6 && remainder > 0) {
        var carry = 1;
        var total =[];
        var sum;
        for (let j = quotient.length -1 ; j >= 0; j--) {
            sum = quotient[j] + carry;
            if (sum > 9 && j!==0) {
                total.unshift(0);
            } else {
                total.unshift(sum);
                carry = 0;
            }
        }
        return total.join("");
    }
    return quotient.join("");
}

for (let i = 0; i < testCase; i++) {
    var n = readline().trim().split('').map(Number);
    var result;
    var sum = 0;
    for (let i = 0; i < n.length; i++) {
        sum += n[i];
    }
    var divisiblebyfour = n.length < 2 ? n[n.length - 1] : ((n[n.length - 2] * 10) + n[n.length - 1]);
    if (n[n.length - 1] % 2 !== 0) {
        console.log(-1);
    } else if (n.length < 2 && n[n.length - 1] < 4) {
        console.log(-1);
    } else {
        console.log(division(n, 6), division(n, 4));
    }
}
}

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

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

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

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

function main() {
var testCase = parseInt(readline());

function division(n, divisor) {
    var remainder;
    var dividend = n[0];
    var quotient = [];

    for (let i = 0; i < n.length; i++) {
        if (dividend < divisor) {
            quotient.push(Math.floor(dividend / divisor));
            remainder = dividend;
            dividend = (remainder * 10) + n[i + 1];
        } else {
            quotient.push(Math.floor(dividend / divisor));
            remainder = dividend % divisor;
            dividend = (remainder * 10) + n[i + 1];
        }
    }

    if (quotient[0] === 0) {
        quotient.shift();
    }
    if (divisor === 6 && remainder > 0) {
        return Number(quotient.join("")) + 1;
    }
    return quotient.join("");
}

for (let i = 0; i < testCase; i++) {
    var n = readline().trim().split('').map(Number);
    var result;
    var sum = 0;
    for (let i = 0; i < n.length; i++) {
        sum += n[i];
    }
    var divisiblebyfour = n.length < 2 ? n[n.length - 1] : ((n[n.length - 2] * 10) + n[n.length - 1]);
    if (n[n.length - 1] % 2 !== 0) {
        console.log(-1);
    } else if (n.length < 2 && n[n.length - 1] < 4) {
        console.log(-1);
    } else {
        console.log(division(n, 6), division(n, 4))
    }
}
}

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

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

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

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

function main() {
var testCase = parseInt(readline());

function division(n, divisor) {
    var remainder;
    var dividend = n[0];
    var quotient = [];

        for (let i = 0; i < n.length; i++) {
            if (dividend < divisor) {
                quotient.push(Math.floor(dividend / divisor));
                remainder = dividend;
                dividend = (remainder * 10) + n[i + 1];
            } else {
                quotient.push(Math.floor(dividend / divisor));
                remainder = dividend % divisor;
                dividend = (remainder * 10) + n[i + 1];
            }
        }

    if (quotient[0] === 0) {
        quotient.shift();
    }
    if (divisor === 6 && remainder > 0) {
        return Number(quotient.join("")) + 1;
    }
    return quotient.join("");
}

for (let i = 0; i < testCase; i++) {
    var n = readline().trim().split('').map(Number);
    var result;
    var sum = 0;
    for (let i = 0; i < n.length; i++) {
        sum += n[i];
    }
    var divisiblebyfour = n.length < 2 ? n[n.length - 1] : ((n[n.length - 2] * 10) + n[n.length - 1]);
    if (n[n.length - 1] % 2 !== 0) {
        console.log(-1);
    } else {
        console.log(division(n, 6), division(n, 4))
    }
}
}

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

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

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

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

function main() {
var testCase = parseInt(readline());

function division(n, divisor) {
    var remainder;
    var dividend = n[0];
    var quotient = [];
    if (n.length < 2) {
        quotient.push(n[0] / divisor);
        return quotient.join("");
    } else {
        for (let i = 0; i < n.length; i++) {
            if (dividend < divisor) {
                quotient.push(Math.floor(dividend / divisor));
                remainder = dividend;
                dividend = (remainder * 10) + n[i + 1];
            } else {
                quotient.push(Math.floor(dividend / divisor));
                remainder = dividend % divisor;
                dividend = (remainder * 10) + n[i + 1];
            }
        }
    }
    if (quotient[0] === 0) {
        quotient.shift();
        return quotient.join("");
    }else{
        return quotient.join("");
    }
}

for (let i = 0; i < testCase; i++) {
    var n = readline().trim().split('').map(Number);
    var result;
    var sum = 0;
    for (let i = 0; i < n.length; i++) {
        sum += n[i];
    }
    var divisiblebyfour = n.length < 2 ? n[n.length - 1] : ((n[n.length - 2] * 10) + n[n.length - 1]) ;
    if ((divisiblebyfour % 4 !== 0) && !(sum % 3 === 0 && n[n.length - 1] % 2 === 0)) {
        console.log(-1);
    }else if ((divisiblebyfour % 4 === 0) && !(sum % 3 === 0 && n[n.length - 1] % 2 === 0)) {
        result = division(n, 4);
        console.log(result, result);
    }else if ((divisiblebyfour % 4 !== 0) && (sum % 3 === 0 && n[n.length - 1] % 2 === 0)) {
        result = division(n, 6);
        console.log(result, result);
    }else if((divisiblebyfour % 4 === 0) && (sum % 3 === 0 && n[n.length - 1] % 2 === 0)){
        console.log(division(n, 6), division(n, 4));
    }
}
}

const solve = (str)=>{
     let n = BigInt(str);
     let min = 6n;
     let max = 4n;
     if(n%2n===1n) return -1;
     let r1 = n%min,r2 = n%max;
     r1 = r1>0n ? (n/min)+1n : n/min;
     r2 = n/max;
     return `${r1} ${r2}`;
}
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();
       console.log(solve(n));
  }
}
main();

const solve = (str)=>{
     let n = BigInt(str);
     let min = BigInt(6);
     let max = BigInt(4);
     if(n%min===BigInt(0)) min = n/min;
     else min = 1;
     if(n%max===BigInt(0)) max = n/max;
     else max = 1;
     if(min===max) return -1;
     else return `${min} ${max}`;
}
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();
       console.log(solve(n));
  }
}
main();

const readline = require('readline')

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

function solve(n) {
    if (n & 1n) return -1
    const a = n / 4n
    const b = ceil(n, 6n)
    return b + ' ' + a
}
function ceil(a, b) {
    const r = a % b
    const f = a / b
    return r ? f + 1n : f
}

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

let lines = 0;
const maxBuses = (n) => {
  switch (n % 4n) {
    case 0n:
      return n / 4n;
    case 1n:
      return -1;
    case 2n:
      return (n - 4n) / 4n + 1n;
    case 3n:
      return -1;
  }
};
const minBuses = (n) => {
  switch (n % 6n) {
    case 0n:
      return n / 6n;
    case 1n:
      return -1;
    case 2n:
      return (n - 6n) / 6n + 2n;
    case 3n:
      return -1;
    case 4n:
      return n / 6n + 1n;
    case 5n:
      return -1;
  }
};

rl.on("line", function (line) {
  if (lines !== 0) {
    const input = BigInt(line);
    const min = minBuses(input);
    const max = maxBuses(input);
    if (min === -1 && max === -1) {
      return console.log("-1");
    }
    console.log(min.toString(), max.toString());
  }
  lines++;
});

'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) {
  if (n % 2n !== 0n) return '-1';
  let min = 0n,
      max = 0n;
  for (let i = 0n; i < n; i++) {
    if ((n - 4n * i) % 6n === 0n) {
      min = i + (n - 4n * i) / 6n;
      break;
    }
  }
  for (let i = 0n; i < n; i++) {
    if ((n - 6n * i) % 4n === 0n) {
      max = i + (n - 6n * i) / 4n;
      break;
    }
  }
  return `${min.toString()} ${max.toString()}`;
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const n = BigInt(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);
}();

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

let ls = [];

function solve() {
    let l = 0;
    let t = parseInt(ls[l++]);
    for (; t > 0; t--){
        const n = parseInt(ls[l++]);
        if (n % 2 == 1 || n < 4){
            console.log(-1);
            continue;
        }

        let x = n % 6 == 0 ? n / 6 : Math.floor(n / 6) + 1;
        let y = Math.floor(n / 4);
        console.log(`${x} ${y}`);
    }
}

rl.on('line', (l) => ls.push(l));
rl.on('close', () => solve());


All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats themselves. Formerly the choice was made by a cashier, but now this is the responsibility of a special seating program. It was found out that the large majority of Berland's inhabitants go to the cinema in order to watch a movie, that's why they want to sit as close to the hall center as possible. Moreover, a company of M people, who come to watch a movie, want necessarily to occupy M successive seats in one row. Let's formulate the algorithm, according to which the program chooses seats and sells tickets. As the request for M seats comes, the program should determine the row number x and the segment [yl, yr] of the seats numbers in this row, where yr - yl + 1 = M. From all such possible variants as a final result the program should choose the one with the minimum function value of total seats remoteness from the center. Say,  — the row and the seat numbers of the most "central" seat. Then the function value of seats remoteness from the hall center is . If the amount of minimum function values is more than one, the program should choose the one that is closer to the screen (i.e. the row number x is lower). If the variants are still multiple, it should choose the one with the minimum yl. If you did not get yet, your task is to simulate the work of this program.

The first line contains two integers N and K (1 ≤ N ≤ 1000, 1 ≤ K ≤ 99) — the amount of requests and the hall size respectively. The second line contains N space-separated integers Mi from the range [1, K] — requests to the program.

Output N lines. In the i-th line output «-1» (without quotes), if it is impossible to find Mi successive seats in one row, otherwise output three numbers x, yl, yr. Separate the numbers with a space.

var lll = readline().split(' ')
var N = +lll[0]
var K = +lll[1]

lll = readline().split(' ')
var xc = (K / 2 | 0)
var yc = (K / 2 | 0)

var kin = []
for (var i = 0; i < K; i++) {
  kin[i] = []
  for (var j = 0; j < K; j++) {
    kin[i][j] = 0
  }
}

for (var i = 0; i < N; i++) {
  var M = +lll[i]
  var sitTo = find(M)
  print(sitTo == -1 ? '-1' : sitTo.join(' '))
}

function toC (x, yl, yr) {
  var s = 0
  var xs = Math.abs(xc - x)
  for (var y = yl; y <= yr; y++)
    s += xs + Math.abs(yc - y)
  return s
}

function find (M) {
  var bs = Infinity
  var bp = [Infinity, Infinity]
  for (var i = 0; i < K; i++) {
    next : for (var j = 0; j < K; j++) {
      for (var k = 0; k < M; k++) {
        if (kin[i][j + k] || j + k >= K) continue next
      }
      var tc = toC(i, j, j + M - 1)
      if (tc < bs || tc == bs && i < bp[0] || tc == bs && i == bp[0] && j < bp[1]) {
        bs = tc
        bp = [i, j]
      }
    }
  }
  if (bs != Infinity) {
    for (var y = bp[1]; y < bp[1] + M; y++) {
      kin[bp[0]][y] = 1
    }
  }
  return bs == Infinity ? -1 : [bp[0] + 1, bp[1] + 1, bp[1] + M]
}

var lll = readline().split(' ')
var N = +lll[0]
var K = +lll[1]

lll = readline().split(' ')
var xc = (K / 2 | 0)
var yc = (K / 2 | 0)

var kin = []
for (var i = 0; i < K; i++) {
  kin[i] = []
  for (var j = 0; j < K; j++) {
    kin[i][j] = 0
  }
}

for (var i = 0; i < N; i++) {
  var M = +lll[i]
  var sitTo = find(M)
  print(sitTo == -1 ? '-1' : sitTo.join(' '))
}

function toC (x, yl, yr) {
  var s = 0
  var xs = Math.abs(xc - x)
  for (var y = yl; y <= yr; y++)
    s += xs + Math.abs(yc - y)
  return s
}

function find (M) {
  var bs = Infinity
  var bp = [Infinity, Infinity]
  next : for (var i = 0; i < K; i++) {
    for (var j = 0; j < K; j++) {
      for (var k = 0; k < M; k++)
        if (kin[i][j + k]) continue next
      var tc = toC(i, j, j + M - 1)
      if (tc < bs || tc == bs && i < bp[0] || tc == bs && i == bp[0] && j < bp[1]) {
        bs = tc
        bp = [i, j]
      }
    }
  }
  if (bs != Infinity) {
    for (var y = bp[1]; y < bp[1] + M; y++) {
      kin[bp[0]][y] = 1
    }
  }
  return bs == Infinity ? -1 : [bp[0] + 1, bp[1] + 1, bp[1] + M]
}

var lll = readline().split(' ')
var N = +lll[0]
var K = +lll[1]

lll = readline().split(' ')
var xc = (K / 2 | 0)
var yc = (K / 2 | 0)

var fn = 0
var kin = []
for (var i = 0; i < K; i++) {
  kin[i] = []
  for (var j = 0; j < K; j++) {
    kin[i][j] = 0
  }
}

for (var i = 0; i < N; i++) {
  var M = +lll[i]
  var sitTo = find(M)
  print(sitTo == -1 ? '-1' : sitTo.join(' '))
}

function toC (x, yl, yr) {
  var s = 0
  var xs = Math.abs(xc - x)
  for (var y = yl; y <= yr; y++)
    s += xs + Math.abs(yc - y)
  return s
}

function find (M) {
  fn++
  var bs = Infinity
  var bp = [Infinity, Infinity]
  for (var i = 0; i < K; i++) {
    next : for (var j = 0; j < K; j++) {
      for (var k = 0; k < M; k++) {
        if (kin[i][j + k]) continue next
      }
      var tc = toC(i, j, j + M - 1)
      if (tc < bs || tc == bs && i < bp[0] || tc == bs && i == bp[0] && j < bp[1]) {
        bs = tc
        bp = [i, j]
      }
    }
  }
  if (bs != Infinity) {
    for (var y = bp[1]; y < bp[1] + M; y++) {
      kin[bp[0]][y] = 1
    }
  }
  return bs == Infinity ? -1 : [bp[0] + 1, bp[1] + 1, bp[1] + M]
}


A sequence of non-negative integers $$$a_1, a_2, \dots, a_n$$$ is called growing if for all $$$i$$$ from $$$1$$$ to $$$n - 1$$$ all ones (of binary representation) in $$$a_i$$$ are in the places of ones (of binary representation) in $$$a_{i + 1}$$$ (in other words, $$$a_i \:\&\: a_{i + 1} = a_i$$$, where $$$\&$$$ denotes bitwise AND). If $$$n = 1$$$ then the sequence is considered growing as well.For example, the following four sequences are growing:   $$$[2, 3, 15, 175]$$$ — in binary it's $$$[10_2, 11_2, 1111_2, 10101111_2]$$$;  $$$[5]$$$ — in binary it's $$$[101_2]$$$;  $$$[1, 3, 7, 15]$$$ — in binary it's $$$[1_2, 11_2, 111_2, 1111_2]$$$;  $$$[0, 0, 0]$$$ — in binary it's $$$[0_2, 0_2, 0_2]$$$. The following three sequences are non-growing:   $$$[3, 4, 5]$$$ — in binary it's $$$[11_2, 100_2, 101_2]$$$;  $$$[5, 4, 3]$$$ — in binary it's $$$[101_2, 100_2, 011_2]$$$;  $$$[1, 2, 4, 8]$$$ — in binary it's $$$[0001_2, 0010_2, 0100_2, 1000_2]$$$. Consider two sequences of non-negative integers $$$x_1, x_2, \dots, x_n$$$ and $$$y_1, y_2, \dots, y_n$$$. Let's call this pair of sequences co-growing if the sequence $$$x_1 \oplus y_1, x_2 \oplus y_2, \dots, x_n \oplus y_n$$$ is growing where $$$\oplus$$$ denotes bitwise XOR.You are given a sequence of integers $$$x_1, x_2, \dots, x_n$$$. Find the lexicographically minimal sequence $$$y_1, y_2, \dots, y_n$$$ such that sequences $$$x_i$$$ and $$$y_i$$$ are co-growing.The sequence $$$a_1, a_2, \dots, a_n$$$ is lexicographically smaller than the sequence $$$b_1, b_2, \dots, b_n$$$ if there exists $$$1 \le k \le n$$$ such that $$$a_i = b_i$$$ for any $$$1 \le i < k$$$ but $$$a_k < b_k$$$.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$). Then $$$t$$$ test cases follow. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — length of the sequence $$$x_i$$$. The second line contains $$$n$$$ integers $$$x_1, x_2, \dots, x_n$$$ ($$$0 \le x_i < 2^{30}$$$) — elements of the sequence $$$x_i$$$. It is guaranteed that the sum of $$$n$$$ overall all test cases doesn't exceed $$$2 \cdot 10^5$$$.

For each test case, print $$$n$$$ integers $$$y_1, y_2, \dots, y_n$$$ ($$$0 \le y_i < 2^{30}$$$) — lexicographically minimal sequence such that such that it's co-growing with given sequence $$$x_i$$$.

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let numbers = +input[z++];
        let arr = input[z++].split(' ').map(Number);
        let binaryArr = [];
        let resultArr = [];

        arr.forEach(element => {
            binaryArr.push(element.toString(2));
        });
        let newBinaryarr = [];
        newBinaryarr.push(binaryArr[0])
        for (let i = 0; i < binaryArr.length; i++) {
            if(i === 0){
                resultArr.push(0);
            }
            else{
                let temp1 = newBinaryarr[i-1].toString().length;
                let temp2 = binaryArr[i].toString().length;
                if(temp1 > temp2){
                    binaryArr[i] = '0'.repeat(temp1 - temp2) + binaryArr[i];
                }
                else{
                    newBinaryarr[i-1] = '0'.repeat(temp2 - temp1) + newBinaryarr[i - 1];
                }
                let max = Math.max(temp1, temp2);
                let pow = 0;
                let total = 0;

                for (let j = max - 1; j >= 0; j--) {
                    if(newBinaryarr[i-1][j] == 1 && binaryArr[i][j] != 1){
                        total += Math.pow(2, pow);
                        pow++;
                    }
                    else{
                        pow++;
                    }
                }
                newBinaryarr.push((total + arr[i]).toString(2));
                resultArr.push(total);
            }
        }
        console.log(resultArr.join(' '));
    }
}

"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());
}
function iInpArr1() {
  return readline()
    .trim()
    .split("")
    .map((cur) => parseInt(cur));
}
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 sqrt = (n) => {
  let low = 1n,
    high = n,
    ans;
  while (low <= high) {
    let mid = (low + high) / 2n;
    if (mid * mid <= n) {
      ans = mid;
      low = mid + 1n;
    } else high = mid - 1n;
  }
  return ans;
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    if (n === 1) console.log(0);
    else {
      let ans = [],
        prev = 0 ^ arr[0];
      ans.push(0);
      for (let i = 1; i < n; i++) {
        let p1 = new Array(30).fill(0);
        let p2 = new Array(30).fill(0);
        let j = arr[i],
          k = 0,
          l = prev;
        while (j > 0) {
          if (j & 1) p1[k] = 1;
          j = j >> 1;
          k++;
        }
        k = 0;
        while (l > 0) {
          if (l & 1) p2[k] = 1;
          l = l >> 1;
          k++;
        }
        let res = 0;
        for (let j = 0; j < 30; j++) {
          if (p2[j] === 1 && p1[j] === 0) res += 1 << j;
        }
        ans.push(res);
        prev = res ^ arr[i];
      }
      console.log(ans.join(" "));
    }
  }
};
solve();

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

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

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

		const ans = [0];
		for (let i = 1, prev = x[0]; i < n; i++) {
			ans[i] = ~x[i] & prev;
			prev = x[i] ^ ans[i];
		}

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

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

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

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

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

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

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

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

function solve() {
   const n = Number(read());
   let maxlen = 0;
   const x = readArray((x) => {
      const binx = decToBin(Number(x));
      if (binx.length > maxlen) {
         maxlen = binx.length;
      }
      return binx;
   });
   const ans = [[0]];
   const a = [x[0]];
   for (let i = 1; i < n; i++) {
      ans.push([]);
      a.push([]);
      for (let j = maxlen - 1; j >= 0; j--) {
         ans[i][j] = a[i - 1][j] && !x[i][j] ? 1 : 0;
         a[i][j] = (x[i][j] ^ ans[i][j]);
      }
   }
   write(ans.map(binToDec).join(' '));
}

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

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 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 l = 0;
    var t = +lines[l++]
    for (var i = 0; i < t; i++) {
        l++
        var arr = lines[l++].trim().split(' ').map(Number)
        console.log(solve(arr))
    }
});

function solve(arr) {
    let prev
    return arr.map((x, idx) => {
        if (idx) {
            let mask = 1
            let r = 0
            let next = 0
            for (let i = 0; i < 31; i++) {
                if (prev & mask) {
                    if (!(x & mask)) {
                        r |= mask
                    }
                } else {
                    // prefer 0 in r
                }
                next |= ((r & mask) ^ (x & mask))
                mask += mask
            }
            prev = next
            return r
        } else {
            prev = x
            return 0
        }
    }).join(' ')
}

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
// import * as readline from 'readline'
// const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
// const ask = (query: string) => new Promise<string>((resolve) => rl.question(query, resolve))
// // Don't forget `rl.close()`.
const INT = Math.floor;
Array.prototype.last = function () {
    return this.length === 0 ? undefined : this[this.length - 1];
};
Array.prototype.isEmpty = function () {
    return this.length === 0;
};
const less = (a, b) => (a == b ? 0 : a < b ? -1 : 1);
const greater = (a, b) => (a == b ? 0 : a < b ? 1 : -1);
const bigIntMax = (...args) => args.reduce((m, e) => (e > m ? e : m));
const bigIntMin = (...args) => args.reduce((m, e) => (e < m ? e : m));
const bigIntAbs = (arg) => (arg < 0 ? -arg : arg);
function read_stdin() {
    return fs.readFileSync(process.env.NODE_ENV === 'debug' ? stdin : process.stdin.fd, 'utf8');
}
class Input {
    constructor(str) {
        this.index = 0;
        this.inputs = (str ? str : read_stdin()).split(/\s+/);
    }
    number() {
        return Number(this.inputs[this.index++]);
    }
    numbers(n) {
        return this.inputs.slice(this.index, (this.index += n)).map(Number);
    }
    bigint() {
        return BigInt(this.inputs[this.index++]);
    }
    bigints(n) {
        return this.inputs.slice(this.index, (this.index += n)).map(BigInt);
    }
    word() {
        return this.inputs[this.index++];
    }
    words(n) {
        return this.inputs.slice(this.index, (this.index += n));
    }
}
function array(len, init) {
    return Array(len).fill(init);
}
function array2(h, w, init) {
    return array(h, 0).map(() => array(w, init));
}
function main() {
    const input = new Input();
    const t = input.number();
    const ans = Array(t);
    for (let i = 0; i < t; i++) {
        const n = input.number();
        const X = input.numbers(n);
        const Y = Array(n);
        let prev = 0;
        for (let j = 0; j < n; j++) {
            if ((prev & X[j]) === prev) {
                Y[j] = 0;
                prev = X[j];
            }
            else {
                const tmp = prev | X[j];
                Y[j] = tmp ^ X[j];
                prev = tmp;
            }
        }
        ans[i] = Y;
    }
    console.log(ans.map((Y) => Y.join(' ')).join('\n'));
}
main();
//# sourceMappingURL=aoj.js.map

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let numbers = +input[z++];
        let arr = input[z++].split(' ').map(Number);
        let binaryArr = [];
        let resultArr = [];

        arr.forEach(element => {
        binaryArr.push(convertToBinary(element))});

        function convertToBinary(element){
            let bin = 0;
            let rem, i = 1, step = 1;
            while (element != 0) {
                rem = element % 2;
                element = parseInt(element / 2);
                bin = bin + rem * i;
                i = i * 10;
            }
            return bin.toString();
        };

        let newBinaryarr = [];
        newBinaryarr.push(binaryArr[0])
        for (let i = 0; i < binaryArr.length; i++) {
            if(i === 0){
                resultArr.push(0);
            }
            else{
                let temp1 = newBinaryarr[i-1].toString().length;
                let temp2 = binaryArr[i].toString().length;
                if(temp1 > temp2){
                    binaryArr[i] = '0'.repeat(temp1 - temp2) + binaryArr[i];
                }
                else{
                    newBinaryarr[i-1] = '0'.repeat(temp2 - temp1) + newBinaryarr[i - 1];
                }
                let max = Math.max(temp1, temp2);
                let pow = 0;
                let total = 0;

                for (let j = max - 1; j >= 0; j--) {
                    if(newBinaryarr[i-1][j] == 1 && binaryArr[i][j] != 1){
                        total += Math.pow(2, pow);
                        pow++;
                    }
                    else{
                        pow++;
                    }
                }
                newBinaryarr.push((total + arr[i]).toString(2));
                resultArr.push(total);
            }
        }
        console.log(...resultArr);
    }
}


In Aramic language words can only represent objects.Words in Aramic have special properties:   A word is a root if it does not contain the same letter more than once.  A root and all its permutations represent the same object.  The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y$$$ in a way that each letter appears once. For example, the root of "aaaa", "aa", "aaa" is "a", the root of "aabb", "bab", "baabb", "ab" is "ab".  Any word in Aramic represents the same object as its root. You have an ancient script in Aramic. What is the number of different objects mentioned in the script?

The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin letters.

Output one integer — the number of different objects mentioned in the given ancient Aramic script.

NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer".

var n = readline();
var words = readline().split(" ");

var keys = {};

words.forEach(function (word) {
    keys[clean(word)] = true;
});

print(Object.keys(keys).length);

function clean(word) {
    var keys = {};
    for (var i = 0; i < word.length; i++) {
        keys[word[i]] = true;
    }
    return Object.keys(keys).sort().join();
}

// ################## //
// 11th October 2019. //
// ################## //

// ####################################################################### //
// Letters of the english alphabet.
const letters = 'abcdefghijklmnopqrstuvwxyz';
// Method to generate bitmasks indicating presence of letters.
function generateBitmaskFor(word){
  var bitmask = '';
  for(var x = 0;x<letters.length;++x){
    if(word.includes(letters[x])) bitmask+='1';
    else bitmask+='0';
  }
  return bitmask;
}
// Generating bitmasks for words given by codeforces.
var wordCount = parseInt(readline());
var wordBitmasks = readline().split(' ').map(function(e){
  return generateBitmaskFor(e);
});
// Solution.
print((new Set(wordBitmasks).size));
// ####################################################################### //

                                 // ###################################### //
                                 // Programming-Credits atifcppprogrammer. //
                                 // ###################################### //