A card pyramid of height $$$1$$$ is constructed by resting two cards against each other. For $$$h>1$$$, a card pyramid of height $$$h$$$ is constructed by placing a card pyramid of height $$$h-1$$$ onto a base. A base consists of $$$h$$$ pyramids of height $$$1$$$, and $$$h-1$$$ cards on top. For example, card pyramids of heights $$$1$$$, $$$2$$$, and $$$3$$$ look as follows:  You start with $$$n$$$ cards and build the tallest pyramid that you can. If there are some cards remaining, you build the tallest pyramid possible with the remaining cards. You repeat this process until it is impossible to build another pyramid. In the end, how many pyramids will you have constructed?

Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain descriptions of test cases. Each test case contains a single integer $$$n$$$ ($$$1\le n\le 10^9$$$) — the number of cards. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^9$$$.

For each test case output a single integer — the number of pyramids you will have constructed in the end.

NoteIn the first test, you construct a pyramid of height $$$1$$$ with $$$2$$$ cards. There is $$$1$$$ card remaining, which is not enough to build a pyramid.In the second test, you build two pyramids, each of height $$$2$$$, with no cards remaining.In the third test, you build one pyramid of height $$$3$$$, with no cards remaining.In the fourth test, you build one pyramid of height $$$3$$$ with $$$9$$$ cards remaining. Then you build a pyramid of height $$$2$$$ with $$$2$$$ cards remaining. Then you build a final pyramid of height $$$1$$$ with no cards remaining.In the fifth test, one card is not enough to build any pyramids.

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

const cache = [0, 2];

function getMaximumPyramids(n) {
    let total = 0;
    let remaining = n;
    while (remaining >= 2) {
        getNextPyramid();
        total++;
    }
    return total;

    function getNextPyramid(h = 1) {
        let required = 2;
        while (required <= remaining){
            required = getRequiredCards(++h);
        }
        remaining -= cache[h-1];
        return h-1;
    }

    function getRequiredCards(h) {
        if (h == 1) return 2;
        else {
            const req = (h * 2) + (h - 1) + (cache[h - 1] || getRequiredCards(h - 1));
            cache[h] = req;
            return req;
        }
    }
}

function main() {
    const n = parseInt(readLine(), 10);
    for (let i = 0; i < n; i++) {
        const result = getMaximumPyramids(parseInt(readLine(), 10));
        console.log(result)
    }
    return;
}

// Input
'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function mandatoryCards(n) { return (3*n*n + n)/2; }

function processPyramids(remaining, nbPyramids) {
    if (remaining <= 1) return nbPyramids;
    var maxHeight = 1;
    while(mandatoryCards(maxHeight) <= remaining ) maxHeight++;
    return processPyramids(remaining-mandatoryCards(maxHeight-1), nbPyramids+1);
}

//main
function main() {
    var nbOfTestCases = parseInt(readline());

    for (var i=0 ; i<nbOfTestCases ; i++) {
        var n = parseInt(readline());
        console.log(processPyramids(n,0));
    }
}

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin
});
let first = true
rl.on('line', (line) => {
  let max = 0;
  let card = +line;
  if (first) {
    first = false
  } else {
    while (card > 1) {
      let maxCard = 2;
      let maxDeck = 1;
      if (maxCard === card) {
        card -= maxCard;
        max++;
      } else {
        while(true) {
          let newMaxDeck = maxDeck + 1;
          let newMaxCard = maxCard + maxDeck + newMaxDeck * 2;
          if (newMaxCard > card) {
            card -= maxCard;
            max++;
            break;
          } else {
            maxCard = newMaxCard;
            maxDeck = newMaxDeck;
          }
        }
      }
    }
    process.stdout.write(`${max}\n`);
  }
})

var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var outputCount = 0;
		var n = nextInt();
		while(n >= 2){
			var count = 1;
			while(true){
				var req = count * 2 + (count - 1);
				if(n < req){
					break;
				}
				n -= req;
				count++;
			}
			outputCount++;
		}
		output[i] = outputCount;
	}
	myout(myconv(output,9));
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const cases = readline();
    var i;
    for (i = 0; i < cases; i++) {
        const line = readline();
        var a = parseInt(line.split(" ")[0]);

        solve(a);
    }
}

function solve(a) {
    var towers = 0;

    if (a < 2) {
        console.log(0);
        return;
    }

    while (a > 1) {
        var floor = 1;
        a -= 2;
        while (a >= cardsForFloor(floor+1)) {
            a -= cardsForFloor(floor+1);
            floor++;
        }
        towers++;
    }

    console.log(towers);
}

const cache = [0, 2];

function cardsForFloor(floor) {
    if (!(floor in cache)) {
        cache[floor] = ((floor)*2 + (floor -1));
    }

    return cache[floor];
}

//Card Constructions

const {EOL} = require('os');

let inp = '';

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

process.stdin.on('end', () => {
    let lines = inp.split(EOL);

    let t = +lines[0];

    let o = {};

    let f = (n) =>  {

    	if(n < 2)  {
    		return 0;
    	}

    	let k = Math.sqrt(2 * n / 3);
    	for(let i = 1; i <= k + 1; i++)  {

    		let r;

    		if(o[i])  {
    			r = o[i];
    		}  else  {
    			o[i] = (i * ((3 * i) + 1)) / 2;
    			r = o[i];
    		}

    		if(r > n)  {
    			return 1 + f(n - (((3 * Math.pow(i - 1, 2)) + (i - 1)) / 2));
    		}
    	}
    }

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

    	process.stdout.write(f(n) + '\n');
    }

    return;
});

const processData = (lines) => {
  const n = +lines[0]
  for (let i=0; i<n; i++) {
    let a = +lines[i+1]

    let acc = 0
    while (a > 2) {
      let sum = 2
      let pos = 0
      while (sum <= a) {
        pos++
        sum += 2 + (pos)*3
        // console.log(sum)
      }
      sum -= 2 + (pos)*3
      acc++
      a -= sum
    }
    if (a === 2) {
      acc++
    }
    console.log(acc)
  }
}

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

// node template.js < A-small.in > A-small.out

function main() {
    var tests = 1;
    tests = nextInt();

    for (let t = 1; t <= tests; t++) {
        let N = nextInt();
        let result = 0;
        while (N >= 2) {
            let cost = find(N);
            N -= cost;
            result++;
        }

        print(result);
    }
}

function find(N) {
    let l = 1, r = N, res = 0;
    while (l <= r) {
        let m = Math.floor((l+r) >> 1);
        if (3*m*(m+1)/2-m <= N) {
            l = m+1;
            res = 3*m*(m+1)/2-m;
        } else {
            r = m-1;
        }
        // console.log(l, r, m, 3*m*(m+1)/2-m);
    }
    return res;
}

// ------- Template ------------------
function newTensor(dimensions, value) {
    let res = [];
    let dim = dimensions[0], subdim = dimensions.slice(1);
    if (subdim.length == 0) {
        for(let i = 0; i < dim; i++) {
            res.push(value);
        }
    } else {
        for(let i = 0; i < dim; i++) {
            res.push(newTensor(subdim, value));
        }
    }
    return res;
}

if (!String.prototype.startsWith) {
    Object.defineProperty(String.prototype, 'startsWith', {
        value: function(search, rawPos) {
            var pos = rawPos > 0 ? rawPos|0 : 0;
            return this.substring(pos, pos + search.length) === search;
        }
    });
}
if (!String.prototype.endsWith) {
    String.prototype.endsWith = function(search, this_len) {
        if (this_len === undefined || this_len > this.length) {
            this_len = this.length;
        }
        return this.substring(this_len - search.length, this_len) === search;
    };
}

var curTokens = [], curToken = 0;

function next() {
    while (curToken >= curTokens.length) {
        curTokens = readline().split(/[\s]+/);
        curToken = 0;
    }
    return curTokens[curToken++];
}

function nextInt() {
    return parseInt(next());
}

// code for nodejs
var inputBuffer = '', curLine = 0;

function readline() {
    return inputBuffer[curLine++];
}

function print(data) {
    process.stdout.write(data + '\n');
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

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

process.stdin.on('end', function () {
    inputBuffer = inputBuffer.split(/[\s]+/);
    main();
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
    3
1 3
100000 100000
2 2

**/

function main() {
    var range = readline();

    for(var r=0;r<range;r++) {
        let remaining = parseInt(readline());
        let h = 0;
        let counter = 0;

        while(remaining > 1) {
            counter++;
            let h = 0;
            while((3*h*h + h) / 2 <= remaining) {
                h++;
            }
            h--;
            let usedCard = (3*h*h + h) / 2;
            remaining = remaining - usedCard;
        }

        console.log(counter);
    }
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = parseInt(readline());
  var currentFloor = 0;
  var nextFloor = 0;
  var count = 0;
  while (n >= 2) {
    var i = 1;
    if (n == 2) {
      count++;
      break;
    } else {
      while (nextFloor - i <= n) {
        currentFloor += i * 3;
        nextFloor = currentFloor + (i + 1) * 3;
        i++;
      }
      n -= currentFloor - i + 1;
      currentFloor = 0;
      nextFloor = 0;
      count++;
    }
  }
  print(count);
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
    5
    3
    14
    15
    24
    1

**/

function main() {
    var range = readline();

    for(var r=0;r<range;r++) {
        var value = parseInt(readline());

        for(var i=0;i<10^9;i++) {
            let p = (3 * Math.pow(i, 2) + i) / 2;
            if(p === value) {
                console.log(1);
                break;
            }
            if(p > value) {
                console.log(i-1);
                break;
            }
        }
    }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
    3
1 3
100000 100000
2 2

**/

function main() {
    var range = readline();

    for(var r=0;r<range;r++) {
        var value = parseInt(readline());
        var counter = 0;

        for(var i=1;i<10^9;i++) {
            let p = (3 * Math.pow(i, 2) + i) / 2;

            if(p === value) {
                console.log(1);
                break;
            }

            if(p > value) {
                console.log(counter);
                break;
            }

            counter++;
        }
    }
}


You are given a string $$$s$$$ consisting of lowercase Latin letters "a", "b" and "c" and question marks "?".Let the number of question marks in the string $$$s$$$ be $$$k$$$. Let's replace each question mark with one of the letters "a", "b" and "c". Here we can obtain all $$$3^{k}$$$ possible strings consisting only of letters "a", "b" and "c". For example, if $$$s = $$$"ac?b?c" then we can obtain the following strings: $$$[$$$"acabac", "acabbc", "acabcc", "acbbac", "acbbbc", "acbbcc", "accbac", "accbbc", "accbcc"$$$]$$$.Your task is to count the total number of subsequences "abc" in all resulting strings. Since the answer can be very large, print it modulo $$$10^{9} + 7$$$.A subsequence of the string $$$t$$$ is such a sequence that can be derived from the string $$$t$$$ after removing some (possibly, zero) number of letters without changing the order of remaining letters. For example, the string "baacbc" contains two subsequences "abc" — a subsequence consisting of letters at positions $$$(2, 5, 6)$$$ and a subsequence consisting of letters at positions $$$(3, 5, 6)$$$.

The first line of the input contains one integer $$$n$$$ $$$(3 \le n \le 200\,000)$$$ — the length of $$$s$$$. The second line of the input contains the string $$$s$$$ of length $$$n$$$ consisting of lowercase Latin letters "a", "b" and "c" and question marks"?".

Print the total number of subsequences "abc" in all strings you can obtain if you replace all question marks with letters "a", "b" and "c", modulo $$$10^{9} + 7$$$.

NoteIn the first example, we can obtain $$$9$$$ strings:  "acabac" — there are $$$2$$$ subsequences "abc",  "acabbc" — there are $$$4$$$ subsequences "abc",  "acabcc" — there are $$$4$$$ subsequences "abc",  "acbbac" — there are $$$2$$$ subsequences "abc",  "acbbbc" — there are $$$3$$$ subsequences "abc",  "acbbcc" — there are $$$4$$$ subsequences "abc",  "accbac" — there is $$$1$$$ subsequence "abc",  "accbbc" — there are $$$2$$$ subsequences "abc",  "accbcc" — there are $$$2$$$ subsequences "abc". So, there are $$$2 + 4 + 4 + 2 + 3 + 4 + 1 + 2 + 2 = 24$$$ subsequences "abc" in total.

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+/), _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 n = +$(), s = $()
  let a = Array(n).fill(0), ab = Array(n).fill(0), abc = Array(n).fill(0), k = 1;
  let MOD = 1e9 + 7;
  if (s[0] == 'a') a[0] = 1
  else if (s[0] == '?') (a[0] = 1, k = 3)
  For(1, n - 1, i => {
    if (s[i] == 'a') {
      a[i] = (a[i - 1] + k) % MOD;
      ab[i] = ab[i - 1];
      abc[i] = abc[i - 1];
    } else if (s[i] == 'b') {
      a[i] = a[i - 1];
      ab[i] = (ab[i - 1] + a[i - 1]) % MOD;
      abc[i] = abc[i - 1];
    } else if (s[i] == 'c') {
      a[i] = a[i - 1];
      ab[i] = ab[i - 1]
      abc[i] = (abc[i - 1] + ab[i - 1]) % MOD;
    } else {
      a[i] = (3 * a[i - 1] + k) % MOD;
      ab[i] = (3 * ab[i - 1] + a[i - 1]) % MOD
      abc[i] = (3 * abc[i - 1] + ab[i - 1]) % MOD
      k = (k * 3) % MOD
    }
  })
  log(abc[n - 1])
}


A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition — when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do. Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation. Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom.   You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously. Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.Note one milliliter equals to one cubic centimeter.

The only line of the input contains four integer numbers d, h, v, e (1 ≤ d, h, v, e ≤ 104), where:   d — the diameter of your cylindrical cup,  h — the initial level of water in the cup,  v — the speed of drinking process from the cup in milliliters per second,  e — the growth of water because of rain if you do not drink from the cup.

If it is impossible to make the cup empty, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line. In the second line print a real number — time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10 - 4. It is guaranteed that if the answer exists, it doesn't exceed 104.

NoteIn the first example the water fills the cup faster than you can drink from it.In the second example area of the cup's bottom equals to , thus we can conclude that you decrease the level of water by  centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in  seconds.

var input = readline().split(' ').map(Number);

var d = input[0];
var h = input[1];
var v = input[2];
var e = input[3];

var pi = Math.PI;

var t = - ((pi * Math.pow(d,2) * h) / (e * pi * Math.pow(d,2) - (4 * v)));

if (t < 0) {
	print('NO');
} else {
	print('YES');
	print(t);
}

var a = readline().split(" ");
var d = parseInt(a[0]);
var h = parseInt(a[1]);
var v = parseInt(a[2]);
var e = parseInt(a[3]);

var V = h * (((d * d) / 4) * Math.PI);

var RainSpeed = e * (((d * d) / 4) * Math.PI);
if(RainSpeed >= v) print("NO"); else{
    print("YES");
    print(V / (v - RainSpeed));
}

var input = readline().split(' ').map(function (item) {
    return parseInt(item);
});
var d = input[0], h = input[1], v = input[2], e = input[3];
var hDecRate = (4*v)/(Math.PI*d*d);
if(hDecRate <= e){
    print("NO");
} else {
    var rate = hDecRate - e;
    print("YES");
    print(h/rate);
}

function getInput() {
    var line = readline();
    var lines = [line];
    while (line = readline()) {
        lines.push(line);
    }
    return lines;
}

function main() {
    const input = getInput().pop().split(' ').map(item => Number(item));
    // diam
    const d = input[0];
    // height
    var h = input[1];
    // speed -
    const v = input[2];
    // speed +
    const e = input[3];

    // s = pi*r^2
    const s = Math.PI * Math.pow(d / 2, 2);
    const spOur = v / s;

    if (e > spOur) {
        print('NO')
    } else {
        var t = h / (spOur - e);
        print('YES')
        print(t)
    }
}

main();


Gargari is jealous that his friend Caisa won the game from the previous problem. He wants to prove that he is a genius.He has a n × n chessboard. Each cell of the chessboard has a number written on it. Gargari wants to place two bishops on the chessboard in such a way that there is no cell that is attacked by both of them. Consider a cell with number x written on it, if this cell is attacked by one of the bishops Gargari will get x dollars for it. Tell Gargari, how to place bishops on the chessboard to get maximum amount of money.We assume a cell is attacked by a bishop, if the cell is located on the same diagonal with the bishop (the cell, where the bishop is, also considered attacked by it).

The first line contains a single integer n (2 ≤ n ≤ 2000). Each of the next n lines contains n integers aij (0 ≤ aij ≤ 109) — description of the chessboard.

On the first line print the maximal number of dollars Gargari will get. On the next line print four integers: x1, y1, x2, y2 (1 ≤ x1, y1, x2, y2 ≤ n), where xi is the number of the row where the i-th bishop should be placed, yi is the number of the column where the i-th bishop should be placed. Consider rows are numbered from 1 to n from top to bottom, and columns are numbered from 1 to n from left to right. If there are several optimal solutions, you can print any of them.

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

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

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

function printValues() {
	var parts = [];
	for (var i = 0; i < arguments.length; i += 2) {
		parts.push(arguments[i]+' = '+arguments[i+1]);
	}
	print(parts.join(', '));
}

function main() {
	var n = parseInt(readline()),
		grid = [];
	for (var i = 0; i < n; ++i) {
		grid.push(tokenizeIntegers(readline()));
	}

	function compute_total(r, c, dr, dc) {
		var total = 0;
		while (r >= 0 && r < n && c >= 0 && c < n) {
			total += grid[r][c];
			r += dr;
			c += dc;
		}
		return total;
	}
	var down_top = new Array(n), down_side = new Array(n),
		up_side = new Array(n), up_bottom = new Array(n);
	for (var i = 0; i < n; ++i) {
		down_top[i] = compute_total(0, i, 1, 1);
		down_side[i] = compute_total(i, 0, 1, 1);
		up_side[i] = compute_total(i, 0, -1, 1);
		up_bottom[i] = compute_total(n-1, i, -1, 1);
	}

	best_info = [[-1, -1, -1], [-1, -1, -1]];
	for (var r = 0; r < n; ++r) {
		for (var c = 0; c < n; ++c) {
			if (r < c) {
				var down = down_top[c-r];
			} else {
				var down = down_side[r-c];
			}
			if (r+c < n) {
				var up = up_side[r+c];
			} else {
				var up = up_bottom[r+c-n+1];
			}
			var info = best_info[(r+c)%2],
				total = down + up - grid[r][c];
			if (total > info[0]) {
				info[0] = total;
				info[1] = r;
				info[2] = c;
			}
		}
	}
	print(best_info[0][0] + best_info[1][0]);
	print(best_info[0][1]+1, best_info[0][2]+1, best_info[1][1]+1, best_info[1][2]+1);
}

main();


You are given $$$q$$$ queries in the following form:Given three integers $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$, find minimum positive integer $$$x_i$$$ such that it is divisible by $$$d_i$$$ and it does not belong to the segment $$$[l_i, r_i]$$$.Can you answer all the queries?Recall that a number $$$x$$$ belongs to segment $$$[l, r]$$$ if $$$l \le x \le r$$$.

The first line contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ lines follow, each containing a query given in the format $$$l_i$$$ $$$r_i$$$ $$$d_i$$$ ($$$1 \le l_i \le r_i \le 10^9$$$, $$$1 \le d_i \le 10^9$$$). $$$l_i$$$, $$$r_i$$$ and $$$d_i$$$ are integers.

For each query print one integer: the answer to this query.

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

  let tmp=0, q=0, lrds=[];

  rl.on('line', (input) => {
      if (tmp==0) {q=Number(input); tmp++;}
      else {
          if (tmp<=q){
          let lrd=input.split(' ').map(a=>{return Number(a)});
           lrds.push(lrd);
            tmp++;}
          }
    if (tmp>q){ rl.close(); therest();}
    return 0;}
);

let therest=function() {

    let res=[];
    for (let i=0; i<q; i++) {
        let l=lrds[i][0];
        let r=lrds[i][1];
        let d=lrds[i][2];

        if (d<l || d>r) {res.push(d);
            console.log(d);}
        else {
            if (r%d==0) console.log(r+d);
            else console.log(Math.ceil(r/d)*d)
        }
//console.log(lrds[i]);

    }
//console.log(T, pairs)
}
//console.log(lngth, str);}

  /*
  rl.question('What do you think of Node.js? ', (answer) => {
    // TODO: Log the answer in a database
    console.log(`Thank you for your valuable feedback: ${answer}`);

    rl.close();
  });*/

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

let l = 0;
let n = 0

rl.on('line', (input) => {
    if (l === 0) {
        n = parseInt(input)
    } else {
        if (l === n)
            rl.close();

        arr = input.split(' ').map(function (item) {
            return parseInt(item, 10);
        });

        if(arr[0]>arr[2]){
          console.log(arr[2])
        } else if(arr[1]<arr[2]){
            console.log(arr[2])
        } else {
            console.log(Math.ceil((arr[1]+1)/arr[2])*arr[2])
        }

        if (l === n)
            return

    }
    l++
});

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

let l = 0;
let n = 0

rl.on('line', (input) => {
    if (l === 0) {
        n = parseInt(input)
    } else {
        if (l === n)rl.close();
        arr = input.split(' ').map(function (item) {
            return parseInt(item, 10);
        });

        if(arr[0]>arr[2]){
          console.log(arr[2])
        } else if(arr[1]<arr[2]){
            console.log(arr[2])
        } else {
            console.log(Math.ceil((arr[1]+1)/arr[2])*arr[2])
        }

        //if (l === n)return

    }
    l++
});

var n = readline();
n = Number(n);

for(var i=0; i<n; i++){
	var lrd = readline().split(' ').map(Number);
	var l = lrd[0];
	var r = lrd[1];
	var d = lrd[2];
	if (d < l) print (d);
	else if (r%d != 0) print (Math.ceil(r/d)*d);
	else print ((r/d+1)*d);
}

//var input = readline()
var t = parseInt(readline())

for(var i=0; i<t; i++) {
    var n = readline().split(' ')
    var a = parseInt(n[0])
    var b = parseInt(n[1])
    var c = parseInt(n[2])

    if(a>c || b<c) print(c)
    else {
        var k = parseInt(b / c)
        //print(k)
        k++
        print(k * c)
    }
}

//

//var input = readline()
var t = parseInt(readline())

for(var i=0; i<t; i++) {
    var n = readline().split(' ')
    var a = parseInt(n[0])
    var b = parseInt(n[1])
    var c = parseInt(n[2])

    if(a>c || b<c) print(c)
    else {
        var k = b % c
        print((b - k) + c)
    }
}

//

		var q=parseInt(readline());
	var s="",y=0,l,r,d;
	for(var i=0;i<q;i++){
		s=readline().split(" ");
		l=parseInt(s[0]);r=parseInt(s[1]);d=parseInt(s[2]);
		if(l>d){print(d);}
		else{r++;print(Math.ceil(r/d)*d);}
	}

function main() {
    var q = +readline();
    r = [];

    for(var i = 0; i < q; i++) {
        var t = readline().split(' ');
        r.push({ l: +t[0], r: +t[1], d: +t[2]});
    }

    var res = [];

    r.forEach(function(item) {

        if(item.l > item.d) {
            res.push(item.d);
        }
        else {
            var f = Math.ceil(item.r / item.d);
            if(item.r % item.d == 0)
                f++;
            res.push(f * item.d);
        }
    });

    res.forEach(function(g) {
        print(g);
    })
}

main();

var q = parseInt(readline());

for (var i = 0; i < q; i++) {
  var _ = readline().split(' ').map(Number);

  var l = _[0];
  var r = _[1];
  var d = _[2];

  if (d < l || d > r) {
    print(d);
  } else {
    var minToBreakFree = Math.floor(r / d);
    print(d * (minToBreakFree + 1));
  }
}

var q = readline()
for(var i=0; i<q; i++) {
    line = readline().split(" ").map(Number)
    l = line[0]
    r = line[1]
    d = line[2]

    if(d < l || d > r) {
        print(d)
    } else {
        print((Math.floor(r/d) + 1) * d)
    }
}

var n = readline();
for(i=0;i<n;i++) {
    seq= readline().split(" ").map(Number);
    var l = seq[0];
    var r = seq[1];
    var d = seq[2];
    if(d < l || d > r) {
        print(d)
    } else {
        print((Math.floor(r/d) + 1) * d)
    }
}

function calc(l, r, d) {
 if (d < l || d > r) {
   return d;
 }

 return d * Math.ceil(r / d) === r ? r + d : d * Math.ceil(r / d);
}

var q = parseInt(readline());
var lrd,l,r,d;

for (var i = 0; i< q; i++) {
  lrd = readline().split(" ");
  // print(lrd);
  l = parseInt(lrd[0]);
  r = parseInt(lrd[1]);
  d = parseInt(lrd[2]);

  print(calc(l, r, d));
}

//var input = readline()
var t = parseInt(readline())

for(var i=0; i<t; i++) {
    var n = readline().split(' ')
    var a = parseInt(n[0])
    var b = parseInt(n[1])
    var c = parseInt(n[2])

    var s = a + b
    if(a>c) print(c)
    else if(a == c) print(s)
    else {
        if(s%c == 0) {
            print(s)
        }
    }
}

//

var q=parseInt(readline());
		for(var i=0;i<q;i++){
			var s=readline().split(" ");
			var l=parseInt(s[0]),r=parseInt(s[1]),d=parseInt(s[2]);
			if(l<=d){
			var y=r+1;
			while(y%d!==0){y++;}print(y);}
			else if(l>d){
				var y=l-1;
			while(y%d!==0){y--;}print(y);}
			}

		var q=parseInt(readline());
		for(var i=0;i<q;i++){
			var s=readline().split(" ");
			var l=parseInt(s[0]),r=parseInt(s[1]),d=parseInt(s[2]);
			var y=r+1;
			while(y%d!==0){y++;}print(y);
		}

var q = readline()
for(var i=0; i<q; i++) {
    line = readline().split(" ")
    l = line[0]
    r = line[1]
    d = line[2]

    if(d < l || d > r) {
        print(d)
    } else {
        print((Math.floor(r/d) + 1) * d)
    }
}

var n = readline().split(' ');
for(i=0;i<n;i++) {
    var seq= readline().split(' ');
    var l = seq[0];
    var r = seq[1];
    var d = seq[2];
    for(j=0;j++;) {
        if((j<l || j>r) && (j%d == 0)) {
            print(j + "\n");
        }
    }
}

var n = readline().split(' ');
for(i=0;i<n;i++) {
    var seq= readline().split(' ');
    var l = seq[0];
    var r = seq[1];
    var d = seq[2];
    var j = 1;
    if(d < l || d > r) {
        print(d)
    } else {
        print((Math.floor(r/d) + 1) * d)
    }
}

var n = readline().split(' ');
for(i=0;i<n;i++) {
    var seq= readline().split(' ');
    var l = seq[0];
    var r = seq[1];
    var d = seq[2];
    for(j=0;j++;) {
        if((j<l || j>r) && (j%d == 0)) {
            print(j);
        }
    }
}

var n = readline().split(' ');
for(i=0;i<n;i++) {
    var seq= readline().split(' ');
    var l = seq[0];
    var r = seq[1];
    var d = seq[2];
    var j = 1;
    for(j=1;j++;) {
        if((j<l || j>r) && (j%d == 0)) {
            print(j + "\n");
            break;
        }
    }
}


This is the easy version of the problem. The only difference is that in this version $$$k = 0$$$.There is an array $$$a_1, a_2, \ldots, a_n$$$ of $$$n$$$ positive integers. You should divide it into a minimal number of continuous segments, such that in each segment there are no two numbers (on different positions), whose product is a perfect square.Moreover, it is allowed to do at most $$$k$$$ such operations before the division: choose a number in the array and change its value to any positive integer. But in this version $$$k = 0$$$, so it is not important.What is the minimum number of continuous segments you should use if you will make changes optimally?

The first line contains a single integer $$$t$$$ $$$(1 \le t \le 1000)$$$  — the number of test cases. The first line of each test case contains two integers $$$n$$$, $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$k = 0$$$). The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^7$$$). It's guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case print a single integer  — the answer to the problem.

NoteIn the first test case the division may be as follows:  $$$[18, 6]$$$  $$$[2, 4]$$$  $$$[1]$$$

// Generated by CoffeeScript 2.4.1
var A, K, N, _, a, dp, i, j, k, l, len, len1, len2, m, min, n, nr, nrs, o, p, q, ref, ref1, ref2, sq, squares, used, xxx;

nrs = function() {
  var i, k, len, ref, results;
  ref = readline().split(' ');
  results = [];
  for (k = 0, len = ref.length; k < len; k++) {
    i = ref[k];
    results.push(parseInt(i));
  }
  return results;
};

nr = function() {
  return nrs()[0];
};

function range(start, stop, step) {
  if (stop == null) {
    stop = start || 0
    start = 0
  }
  if (!step) step = stop < start ? -1 : 1

  var length = Math.max(Math.ceil((stop - start) / step), 0)
  var range = Array(length)

  for (var idx = 0; idx < length; idx++, start += step) range[idx] = start

  return range;
}
;

min = function(lst) {
  var best, item, k, len;
  best = lst[0];
  for (k = 0, len = lst.length; k < len; k++) {
    item = lst[k];
    best = item < best ? item : best;
  }
  return best;
};

n = 10000000;

squares = (function() {
  var k, results;
  results = [];
  for (i = k = 1; k < 3162; i = ++k) {
    results.push(i * i);
  }
  return results;
})();

p = (function() {
  var k, ref, results;
  results = [];
  for (i = k = 0, ref = n + 1; (0 <= ref ? k < ref : k > ref); i = 0 <= ref ? ++k : --k) {
    results.push(i);
  }
  return results;
})();

for (i = k = 1, ref = n + 1; (1 <= ref ? k < ref : k > ref); i = 1 <= ref ? ++k : --k) {
  if (p[i] === i) {
    for (l = 0, len = squares.length; l < len; l++) {
      sq = squares[l];
      if (i * sq > n) {
        break;
      }
      p[i * sq] = i;
    }
  }
}

for (_ = m = 0, ref1 = nr(); (0 <= ref1 ? m < ref1 : m > ref1); _ = 0 <= ref1 ? ++m : --m) {
  xxx = nrs();
  N = xxx[0];
  K = xxx[1];
  A = (function() {
    var len1, o, ref2, results;
    ref2 = nrs();
    results = [];
    for (o = 0, len1 = ref2.length; o < len1; o++) {
      a = ref2[o];
      results.push(p[a]);
    }
    return results;
  })();
  dp = (function() {
    var len1, o, ref2, results;
    ref2 = range(K + 1);
    results = [];
    for (o = 0, len1 = ref2.length; o < len1; o++) {
      _ = ref2[o];
      results.push(N);
    }
    return results;
  })();
  dp[0] = 1;
  used = (function() {
    var o, ref2, results;
    results = [];
    for (_ = o = 0, ref2 = K + 1; (0 <= ref2 ? o < ref2 : o > ref2); _ = 0 <= ref2 ? ++o : --o) {
      results.push({});
    }
    return results;
  })();
  for (o = 0, len1 = A.length; o < len1; o++) {
    a = A[o];
    ref2 = range(K, -1, -1);
    for (q = 0, len2 = ref2.length; q < len2; q++) {
      j = ref2[q];
      if (dp[j] === N) {
        continue;
      }
      if (a in used[j]) {
        if (j < K && dp[j + 1] > dp[j]) {
          dp[j + 1] = dp[j];
          used[j + 1] = used[j];
        }
        dp[j] += 1;
        used[j] = {};
      }
      used[j][a] = 1;
    }
  }
  print(min(dp));
}

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiamltbTg5LmpzIiwic291cmNlUm9vdCI6Ii4uIiwic291cmNlcyI6WyJjb2ZmZWVcXGppbW04OS5jb2ZmZWUiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQUEsQ0FBQSxFQUFBLENBQUEsRUFBQSxDQUFBLEVBQUEsQ0FBQSxFQUFBLENBQUEsRUFBQSxFQUFBLEVBQUEsQ0FBQSxFQUFBLENBQUEsRUFBQSxDQUFBLEVBQUEsQ0FBQSxFQUFBLEdBQUEsRUFBQSxJQUFBLEVBQUEsSUFBQSxFQUFBLENBQUEsRUFBQSxHQUFBLEVBQUEsQ0FBQSxFQUFBLEVBQUEsRUFBQSxHQUFBLEVBQUEsQ0FBQSxFQUFBLENBQUEsRU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G5cdHh4eCA9IG5ycygpXG5cdE4gPSB4eHhbMF1cblx0SyA9IHh4eFsxXVxuXHRBID0gKHBbYV0gZm9yIGEgaW4gbnJzKCkpXG5cdGRwID0gKE4gZm9yIF8gaW4gcmFuZ2UgSysxKVxuXHRkcFswXSA9IDFcblx0dXNlZCA9ICh7fSBmb3IgXyBpbiBbMC4uLksrMV0pXG5cdGZvciBhIGluIEFcblx0XHRmb3IgaiBpbiByYW5nZSBLLC0xLC0xXG5cdFx0XHRpZiBkcFtqXSA9PSBOIHRoZW4gY29udGludWUgXG5cdFx0XHRpZiBhIG9mIHVzZWRbal1cblx0XHRcdFx0aWYgaiA8IEsgYW5kIGRwW2ogKyAxXSA+IGRwW2pdXG5cdFx0XHRcdFx0ZHBbaiArIDFdID0gZHBbal1cblx0XHRcdFx0XHR1c2VkW2ogKyAxXSA9IHVzZWRbal1cblx0XHRcdFx0ZHBbal0gKz0gMVxuXHRcdFx0XHR1c2VkW2pdID0ge31cblx0XHRcdHVzZWRbal1bYV0gPSAxXG5cdHByaW50IG1pbiBkcFxuIl19
//# sourceURL=c:\github\2021\009-CodeForces#708\1497E2\coffee\jimm89.coffee

// Generated by CoffeeScript 2.4.1
  // Problem: hittar inte något kommando som kan exekvera
var N, _, f, k, len, nr, nrs, p2, prepare, randint, ref,
  indexOf = [].indexOf;

nrs = function() {
  var i, k, len, ref, results;
  ref = readline().split(' ');
  results = [];
  for (k = 0, len = ref.length; k < len; k++) {
    i = ref[k];
    results.push(parseInt(i));
  }
  return results;
};

nr = function() {
  return nrs()[0];
};

function range(start, stop, step) {
  if (stop == null) {
    stop = start || 0
    start = 0
  }
  if (!step) step = stop < start ? -1 : 1

  var length = Math.max(Math.ceil((stop - start) / step), 0)
  var range = Array(length)

  for (var idx = 0; idx < length; idx++, start += step) range[idx] = start

  return range;
}
;

//##################################################
N = 3162;

p2 = [];

randint = function(min, max) {
  return min + Math.floor(Math.random() * (max - min + 1));
};

prepare = function() {
  var c, i, j, k, l, len, len1, len2, m, p, ref, ref1, ref2, results;
  p = (function() {
    var k, len, ref, results;
    ref = range(N);
    results = [];
    for (k = 0, len = ref.length; k < len; k++) {
      i = ref[k];
      results.push(1);
    }
    return results;
  })();
  ref = range(2, N);
  for (k = 0, len = ref.length; k < len; k++) {
    i = ref[k];
    if (p[i]) {
      ref1 = range(2 * i, N, i);
      for (l = 0, len1 = ref1.length; l < len1; l++) {
        j = ref1[l];
        p[j] = 0;
      }
    }
  }
  ref2 = range(2, N);
  results = [];
  for (m = 0, len2 = ref2.length; m < len2; m++) {
    c = ref2[m];
    if (p[c] === 1) {
      results.push(c * c);
    }
  }
  return results;
};

f = function(a) {
  var ans, hash, k, kl, l, len, len1, q, r, r0;
  ans = 1;
  kl = {};
  hash = {};
  for (k = 0, len = a.length; k < len; k++) {
    r0 = a[k];
    if (indexOf.call(hash, r0) >= 0) {
      r = hash[r0];
    } else {
      r = r0;
      for (l = 0, len1 = p2.length; l < len1; l++) {
        q = p2[l];
        if (r < q) {
          break;
        }
        while (r % q === 0) {
          r = Math.floor(r / q);
        }
      }
      hash[r0] = r;
    }
    if (r in kl) {
      ans += 1;
      kl = {};
    }
    kl[r] = 1;
  }
  return ans;
};

p2 = prepare();

ref = range(nr());
for (k = 0, len = ref.length; k < len; k++) {
  _ = ref[k];
  _ = nrs();
  print(f(nrs()));
}

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiamF2YXNjcmlwdC5qcyIsInNvdXJjZVJvb3QiOiIuLiIsInNvdXJjZXMiOlsiY29mZmVlXFxqYXZhc2NyaXB0LmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7QUFBQSxJQUFBLENBQUEsRUFBQSxDQUFBLEVBQUEsQ0FBQSxFQUFBLENBQUEsRUFBQSxHQUFBLEVBQUEsRUFBQSxFQUFBLEdBQUEsRUFBQSxFQUFBLEVBQUEsT0FBQSxFQUFBLE9BQUEsRUFBQSxHQUFBO0VB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cblx0XHRcdFx0cFtqXSA9IDBcclxuXHRjKmMgZm9yIGMgaW4gcmFuZ2UgMixOIHdoZW4gcFtjXT09MVxyXG5cclxuZiA9IChhKSAtPlxyXG5cdGFucyA9IDFcclxuXHRrbCA9IHt9XHJcblx0aGFzaCA9IHt9XHJcblx0Zm9yIHIwIGluIGFcclxuXHRcdGlmIHIwIGluIGhhc2hcclxuXHRcdFx0ciA9IGhhc2hbcjBdXHJcblx0XHRlbHNlXHJcblx0XHRcdHIgPSByMFxyXG5cdFx0XHRmb3IgcSBpbiBwMlxyXG5cdFx0XHRcdGlmIHIgPCBxXHJcblx0XHRcdFx0XHRicmVha1xyXG5cdFx0XHRcdHdoaWxlIHIgJSBxID09IDBcclxuXHRcdFx0XHRcdHIgLy89IHFcclxuXHRcdFx0aGFzaFtyMF0gPSByXHJcblx0XHRpZiByIG9mIGtsXHJcblx0XHRcdGFucyArPSAxXHJcblx0XHRcdGtsID0ge31cclxuXHRcdGtsW3JdID0gMVxyXG5cdGFuc1xyXG5cclxucDIgPSBwcmVwYXJlKClcclxuZm9yIF8gaW4gcmFuZ2UgbnIoKVxyXG5cdF8gPSBucnMoKVxyXG5cdHByaW50IGYgbnJzKClcclxuIl19
//# sourceURL=c:\github\2021\010\coffee\javascript.coffee

// Generated by CoffeeScript 2.4.1
var N, currentLine, f, input, inputString, main, nr, nrs, p2, prepare, print, randint,
  indexOf = [].indexOf;

print = console.log;

process.stdin.resume();

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

inputString = '';

currentLine = 0;

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

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

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

nr = function() {
  return parseInt(input());
};

nrs = function() {
  var i, k, len, ref, results;
  ref = input().split(' ');
  results = [];
  for (k = 0, len = ref.length; k < len; k++) {
    i = ref[k];
    results.push(parseInt(i));
  }
  return results;
};

function range(start, stop, step) {
  if (stop == null) {
    stop = start || 0
    start = 0
  }
  if (!step) step = stop < start ? -1 : 1

  var length = Math.max(Math.ceil((stop - start) / step), 0)
  var range = Array(length)

  for (var idx = 0; idx < length; idx++, start += step) range[idx] = start

  return range;
}
  // range = (start, stop, step) ->
  // 	if stop == undefined
  // 		stop = start || 0
  // 		start = 0
  // 	if step == undefined
  // 		step = if stop < start then -1 else 1
  // 	length = Math.max(Math.ceil((stop - start) / step), 0)
  // 	i for i in [start...start+length] by step
;

//##################################################
N = 3162;

p2 = [];

randint = function(min, max) {
  return min + Math.floor(Math.random() * (max - min + 1));
};

prepare = function() {
  var c, i, j, k, l, len, len1, len2, m, p, ref, ref1, ref2, results;
  p = (function() {
    var k, len, ref, results;
    ref = range(N);
    results = [];
    for (k = 0, len = ref.length; k < len; k++) {
      i = ref[k];
      results.push(1);
    }
    return results;
  })();
  ref = range(2, N);
  for (k = 0, len = ref.length; k < len; k++) {
    i = ref[k];
    if (p[i]) {
      ref1 = range(2 * i, N, i);
      for (l = 0, len1 = ref1.length; l < len1; l++) {
        j = ref1[l];
        p[j] = 0;
      }
    }
  }
  ref2 = range(2, N);
  results = [];
  for (m = 0, len2 = ref2.length; m < len2; m++) {
    c = ref2[m];
    if (p[c] === 1) {
      results.push(c * c);
    }
  }
  return results;
};

f = function(a) {
  var ans, hash, k, kl, l, len, len1, q, r, r0;
  ans = 1;
  kl = {};
  hash = {};
  for (k = 0, len = a.length; k < len; k++) {
    r0 = a[k];
    if (indexOf.call(hash, r0) >= 0) {
      r = hash[r0];
    } else {
      r = r0;
      for (l = 0, len1 = p2.length; l < len1; l++) {
        q = p2[l];
        if (r < q) {
          break;
        }
        while (r % q === 0) {
          r = Math.floor(r / q);
        }
      }
      hash[r0] = r;
    }
    if (r in kl) {
      ans += 1;
      kl = {};
    }
    kl[r] = 1;
  }
  return ans;
};

main = function() {
  var _, k, len, ref, results;
  p2 = prepare();
  ref = range(nr());
  results = [];
  for (k = 0, len = ref.length; k < len; k++) {
    _ = ref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IHt9XG5cdGZvciByMCBpbiBhXG5cdFx0aWYgcjAgaW4gaGFzaFxuXHRcdFx0ciA9IGhhc2hbcjBdXG5cdFx0ZWxzZVxuXHRcdFx0ciA9IHIwXG5cdFx0XHRmb3IgcSBpbiBwMlxuXHRcdFx0XHRpZiByIDwgcVxuXHRcdFx0XHRcdGJyZWFrXG5cdFx0XHRcdHdoaWxlIHIgJSBxID09IDBcblx0XHRcdFx0XHRyIC8vPSBxXG5cdFx0XHRoYXNoW3IwXSA9IHJcblx0XHRpZiByIG9mIGtsXG5cdFx0XHRhbnMgKz0gMVxuXHRcdFx0a2wgPSB7fVxuXHRcdGtsW3JdID0gMVxuXHRhbnNcblxubWFpbiA9IC0+XG5cdHAyID0gcHJlcGFyZSgpXG5cdGZvciBfIGluIHJhbmdlIG5yKClcblx0XHRbXyxfXSA9IG5ycygpXG5cdFx0cHJpbnQgZiBucnMoKVxuIl19
//# sourceURL=c:\github\2021\010\coffee\app.coffee

// Generated by CoffeeScript 2.4.1
var N, currentLine, f, input, inputString, main, nr, nrs, p2, prepare, print, randint,
  indexOf = [].indexOf;

print = console.log;

process.stdin.resume();

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

inputString = '';

currentLine = 0;

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

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

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

nr = function() {
  return parseInt(input());
};

nrs = function() {
  var i, k, len, ref, results;
  ref = input().split(' ');
  results = [];
  for (k = 0, len = ref.length; k < len; k++) {
    i = ref[k];
    results.push(parseInt(i));
  }
  return results;
};

// range = (start, stop, step) ->
// 	if stop == undefined
// 		stop = start || 0
// 		start = 0
// 	if step == undefined
// 		step = if stop < start then -1 else 1
// 	length = Math.max(Math.ceil((stop - start) / step), 0)
// 	i for i in [start...start+length] by step

//##################################################
N = 3162;

p2 = [];

randint = function(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
};

prepare = function() {
  var c, i, j, k, l, m, p, ref, ref1, ref2, ref3, ref4, results;
  p = (function() {
    var k, ref, results;
    results = [];
    for (i = k = 0, ref = N; (0 <= ref ? k < ref : k > ref); i = 0 <= ref ? ++k : --k) {
      results.push(1);
    }
    return results;
  })();
  for (i = k = 2, ref = N; (2 <= ref ? k < ref : k > ref); i = 2 <= ref ? ++k : --k) {
    if (p[i]) {
      for (j = l = ref1 = 2 * i, ref2 = N, ref3 = i; ref3 !== 0 && (ref3 > 0 ? l < ref2 : l > ref2); j = l += ref3) {
        p[j] = 0;
      }
    }
  }
  results = [];
  for (c = m = 2, ref4 = N; (2 <= ref4 ? m < ref4 : m > ref4); c = 2 <= ref4 ? ++m : --m) {
    if (p[c] === 1) {
      results.push(c * c);
    }
  }
  return results;
};

f = function(a) {
  var ans, hash, k, kl, l, len, len1, q, r, r0;
  ans = 1;
  kl = {};
  hash = {};
  for (k = 0, len = a.length; k < len; k++) {
    r0 = a[k];
    if (indexOf.call(hash, r0) >= 0) {
      r = hash[r0];
    } else {
      r = r0;
      for (l = 0, len1 = p2.length; l < len1; l++) {
        q = p2[l];
        if (r < q) {
          break;
        }
        while (r % q === 0) {
          r = Math.floor(r / q);
        }
      }
      hash[r0] = r;
    }
    if (r in kl) {
      ans += 1;
      kl = {};
    }
    kl[r] = 1;
  }
  return ans;
};

main = function() {
  var _, k, ref, results;
  p2 = prepare();
  results = [];
  for (_ = k = 0, ref = nr(); (0 <= ref ? k < ref : k > ref); _ = 0 <= ref ? ++k : --k) {
    [_, _] = nrs();
    results.push(print(f(nrs())));
  }
  return results;
};

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLmpzIiwic291cmNlUm9vdCI6Ii4uIiwic291cmNlcyI6WyJjb2ZmZWVcXGFwcC5jb2ZmZWUiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQUEsQ0FBQSxFQUFBLFdBQUEsRUFBQSxDQU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cmUgPSAoKSAtPlxuXHRwID0gKDEgZm9yIGkgaW4gWzAuLi5OXSlcblx0Zm9yIGkgaW4gWzIuLi5OXVxuXHRcdGlmIHBbaV1cblx0XHRcdGZvciBqIGluIFsyKmkuLi5OXSBieSBpXG5cdFx0XHRcdHBbal0gPSAwXG5cdGMqYyBmb3IgYyBpbiBbMi4uLk5dIHdoZW4gcFtjXT09MVxuXG5mID0gKGEpIC0+XG5cdGFucyA9IDFcblx0a2wgPSB7fVxuXHRoYXNoID0ge31cblx0Zm9yIHIwIGluIGFcblx0XHRpZiByMCBpbiBoYXNoXG5cdFx0XHRyID0gaGFzaFtyMF1cblx0XHRlbHNlXG5cdFx0XHRyID0gcjBcblx0XHRcdGZvciBxIGluIHAyXG5cdFx0XHRcdGlmIHIgPCBxXG5cdFx0XHRcdFx0YnJlYWtcblx0XHRcdFx0d2hpbGUgciAlIHEgPT0gMFxuXHRcdFx0XHRcdHIgLy89IHFcblx0XHRcdGhhc2hbcjBdPXJcblx0XHRpZiByIG9mIGtsXG5cdFx0XHRhbnMgKz0gMVxuXHRcdFx0a2wgPSB7fVxuXHRcdGtsW3JdID0gMVxuXHRhbnNcblxubWFpbiA9IC0+XG5cdHAyID0gcHJlcGFyZSgpXG5cdGZvciBfIGluIFswLi4ubnIoKV1cblx0XHRbXyxfXSA9IG5ycygpXG5cdFx0cHJpbnQgZiBucnMoKVxuIl19
//# sourceURL=c:\github\2021\010\coffee\app.coffee

// Generated by CoffeeScript 2.4.1
var N, currentLine, f, input, inputString, main, nr, nrs, p2, prepare, print, randint, range,
  indexOf = [].indexOf;

print = console.log;

process.stdin.resume();

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

inputString = '';

currentLine = 0;

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

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

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

nr = function() {
  return parseInt(input());
};

nrs = function() {
  var i, k, len, ref, results;
  ref = input().split(' ');
  results = [];
  for (k = 0, len = ref.length; k < len; k++) {
    i = ref[k];
    results.push(parseInt(i));
  }
  return results;
};

range = function(start, stop, step) {
  var i, k, length, ref, ref1, ref2, results;
  if (stop === void 0) {
    stop = start || 0;
    start = 0;
  }
  if (step === void 0) {
    step = stop < start ? -1 : 1;
  }
  length = Math.max(Math.ceil((stop - start) / step), 0);
  results = [];
  for (i = k = ref = start, ref1 = start + length, ref2 = step; ref2 !== 0 && (ref2 > 0 ? k < ref1 : k > ref1); i = k += ref2) {
    results.push(i);
  }
  return results;
};

//##################################################
N = 3162;

p2 = [];

randint = function(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
};

prepare = function() {
  var c, i, j, k, l, len, len1, len2, m, p, ref, ref1, ref2, results;
  p = (function() {
    var k, len, ref, results;
    ref = range(N);
    results = [];
    for (k = 0, len = ref.length; k < len; k++) {
      i = ref[k];
      results.push(1);
    }
    return results;
  })();
  ref = range(2, N);
  for (k = 0, len = ref.length; k < len; k++) {
    i = ref[k];
    if (p[i]) {
      ref1 = range(2 * i, N, i);
      for (l = 0, len1 = ref1.length; l < len1; l++) {
        j = ref1[l];
        p[j] = 0;
      }
    }
  }
  ref2 = range(2, N);
  results = [];
  for (m = 0, len2 = ref2.length; m < len2; m++) {
    c = ref2[m];
    if (p[c] === 1) {
      results.push(c * c);
    }
  }
  return results;
};

f = function(a) {
  var ans, hash, k, kl, l, len, len1, q, r, r0;
  ans = 1;
  kl = {};
  hash = {};
  for (k = 0, len = a.length; k < len; k++) {
    r0 = a[k];
    if (indexOf.call(hash, r0) >= 0) {
      r = hash[r0];
    } else {
      r = r0;
      for (l = 0, len1 = p2.length; l < len1; l++) {
        q = p2[l];
        if (r < q) {
          break;
        }
        while (r % q === 0) {
          r = Math.floor(r / q);
        }
      }
      hash[r0] = r;
    }
    if (r in kl) {
      ans += 1;
      kl = {};
    }
    kl[r] = 1;
  }
  return ans;
};

main = function() {
  var _, k, len, ref, results;
  p2 = prepare();
  ref = range(nr());
  results = [];
  for (k = 0, len = ref.length; k < len; k++) {
    _ = ref[k];
    [_, _] = nrs();
    results.push(print(f(nrs())));
  }
  return results;
};

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLmpzIiwic291cmNlUm9vdCI6Ii4uIiwic291cmNlcyI6WyJjb2ZmZWVcXGFwcC5jb2ZmZWUiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQUEsQ0FBQSxFQUFBLFdBQUEsRUFBQSxDQUFBLEVBQUEsS0FBQSxFQUFBLFdBQUEsRUFBQSxJQUFBLEVBQUEsRUFBQSxFQUFBLEdBQUEsRUFBQSxFQUFBLEVBQUEsT0FBQSxFQUFBLEtBQUEsRUFBQSxPQUFBLEVBQUEsS0FBQTtFQUFBOztBQUFBLEtBQUEsR0FBUSxPQUFPLENBQUM7O0FBRWhCLE9BQU8sQ0FBQyxLQUFLLENBQUMsTUFBZCxDQUFBOztBQUNBLE9BQU8sQ0FBQyxLQUFLLENBQUMsV0FBZCxDQUEwQixPQUExQjs7QUFFQSxXQUFBLEdBQWM7O0FBQ2QsV0FBQSxHQUFjOztBQUVkLE9BQU8sQ0FBQyxLQUFLLENBQUMsRUFBZCxDQUFpQixNQUFqQixFQUF5QixRQUFBLENBQUMsVUFBRCxDQUFBO1NBQWdCLFdBQUEsSUFBZTtBQUEvQixDQUF6Qjs7QUFFQSxPQUFPLENBQUMsS0FBSyxDQUFDLEVBQWQsQ0FBaUIsS0FBakIsRUFBd0IsUUFBQSxDQUFDLENBQUQsQ0FBQTtFQUN2QixXQUFBLEdBQWMsV0FBVyxDQUFDLElBQVosQ0FBQSxDQUFrQixDQUFDLEtBQW5CLENBQXlCLElBQXpCLENBQThCLENBQUMsR0FBL0IsQ0FBbUMsUUFBQSxDQUFDLE1BQUQsQ0FBQTtXQUFZLE1BQU0sQ0FBQyxJQUFQLENBQUE7RUFBWixDQUFuQztTQUNkLElBQUEs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ixpXG5cdFx0XHRcdHBbal0gPSAwXG5cdGMqYyBmb3IgYyBpbiByYW5nZSAyLE4gd2hlbiBwW2NdPT0xXG5cbmYgPSAoYSkgLT5cblx0YW5zID0gMVxuXHRrbCA9IHt9XG5cdGhhc2ggPSB7fVxuXHRmb3IgcjAgaW4gYVxuXHRcdGlmIHIwIGluIGhhc2hcblx0XHRcdHIgPSBoYXNoW3IwXVxuXHRcdGVsc2Vcblx0XHRcdHIgPSByMFxuXHRcdFx0Zm9yIHEgaW4gcDJcblx0XHRcdFx0aWYgciA8IHFcblx0XHRcdFx0XHRicmVha1xuXHRcdFx0XHR3aGlsZSByICUgcSA9PSAwXG5cdFx0XHRcdFx0ciAvLz0gcVxuXHRcdFx0aGFzaFtyMF09clxuXHRcdGlmIHIgb2Yga2xcblx0XHRcdGFucyArPSAxXG5cdFx0XHRrbCA9IHt9XG5cdFx0a2xbcl0gPSAxXG5cdGFuc1xuXG5tYWluID0gLT5cblx0cDIgPSBwcmVwYXJlKClcblx0Zm9yIF8gaW4gcmFuZ2UgbnIoKVxuXHRcdFtfLF9dID0gbnJzKClcblx0XHRwcmludCBmIG5ycygpXG4iXX0=
//# sourceURL=c:\github\2021\010\coffee\app.coffee

// Generated by CoffeeScript 2.4.1
  //_ = require 'underscore'

  //range = _.range
var N, currentLine, f, input, inputString, main, nr, nrs, p2, prepare, print, randint,
  indexOf = [].indexOf;

print = console.log;

process.stdin.resume();

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

inputString = '';

currentLine = 0;

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

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

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

nr = function() {
  return parseInt(input());
};

nrs = function() {
  var i, k, len, ref, results;
  ref = input().split(' ');
  results = [];
  for (k = 0, len = ref.length; k < len; k++) {
    i = ref[k];
    results.push(parseInt(i));
  }
  return results;
};

//##################################################
N = 3162;

p2 = [];

randint = function(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
};

prepare = function() {
  var c, i, j, k, l, m, p, ref, ref1, ref2, ref3, ref4, results;
  p = (function() {
    var k, ref, results;
    results = [];
    for (i = k = 0, ref = N; (0 <= ref ? k < ref : k > ref); i = 0 <= ref ? ++k : --k) {
      results.push(1);
    }
    return results;
  })();
  for (i = k = 2, ref = N; (2 <= ref ? k < ref : k > ref); i = 2 <= ref ? ++k : --k) {
    if (p[i]) {
      for (j = l = ref1 = 2 * i, ref2 = N, ref3 = i; ref3 !== 0 && (ref3 > 0 ? l < ref2 : l > ref2); j = l += ref3) {
        p[j] = 0;
      }
    }
  }
  results = [];
  for (c = m = 2, ref4 = N; (2 <= ref4 ? m < ref4 : m > ref4); c = 2 <= ref4 ? ++m : --m) {
    if (p[c] === 1) {
      results.push(c * c);
    }
  }
  return results;
};

f = function(a) {
  var ans, hash, k, kl, l, len, len1, q, r, r0;
  ans = 1;
  kl = {};
  hash = {};
  for (k = 0, len = a.length; k < len; k++) {
    r0 = a[k];
    if (indexOf.call(hash, r0) >= 0) {
      r = hash[r0];
    } else {
      r = r0;
      for (l = 0, len1 = p2.length; l < len1; l++) {
        q = p2[l];
        if (r < q) {
          break;
        }
        while (r % q === 0) {
          r = Math.floor(r / q);
        }
      }
      hash[r0] = r;
    }
    if (r in kl) {
      ans += 1;
      kl = {};
    }
    kl[r] = 1;
  }
  return ans;
};

main = function() {
  var _, k, ref, results;
  //start = Date.now()
  p2 = prepare();
  results = [];
  for (_ = k = 0, ref = nr(); (0 <= ref ? k < ref : k > ref); _ = 0 <= ref ? ++k : --k) {
    [_, _] = nrs();
    results.push(print(f(nrs())));
  }
  return results;
};

// seed = 1;
// random = () ->
// 	x = Math.sin(seed++) * 10000
// 	x - Math.floor(x)

// print f (Math.floor 1 + 2000000 * random() for i in range 200000)
// #f([9790577 for i in range(200000)])
//print Date.now() - start,'ms'

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWx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XHRcdFx0XHRwW2pdID0gMFxuXHRjKmMgZm9yIGMgaW4gWzIuLi5OXSB3aGVuIHBbY109PTFcblxuZiA9IChhKSAtPlxuXHRhbnMgPSAxXG5cdGtsID0ge31cblx0aGFzaCA9IHt9XG5cdGZvciByMCBpbiBhXG5cdFx0aWYgcjAgaW4gaGFzaFxuXHRcdFx0ciA9IGhhc2hbcjBdXG5cdFx0ZWxzZVxuXHRcdFx0ciA9IHIwXG5cdFx0XHRmb3IgcSBpbiBwMlxuXHRcdFx0XHRpZiByIDwgcVxuXHRcdFx0XHRcdGJyZWFrXG5cdFx0XHRcdHdoaWxlIHIgJSBxID09IDBcblx0XHRcdFx0XHRyIC8vPSBxXG5cdFx0XHRoYXNoW3IwXT1yXG5cdFx0aWYgciBvZiBrbFxuXHRcdFx0YW5zICs9IDFcblx0XHRcdGtsID0ge31cblx0XHRrbFtyXSA9IDFcblx0YW5zXG5cbm1haW4gPSAtPlxuXHQjc3RhcnQgPSBEYXRlLm5vdygpXG5cdHAyID0gcHJlcGFyZSgpXG5cdGZvciBfIGluIFswLi4ubnIoKV1cblx0XHRbXyxfXSA9IG5ycygpXG5cdFx0cHJpbnQgZiBucnMoKVxuXG5cdCMgc2VlZCA9IDE7XG5cdCMgcmFuZG9tID0gKCkgLT5cblx0IyBcdHggPSBNYXRoLnNpbihzZWVkKyspICogMTAwMDBcblx0IyBcdHggLSBNYXRoLmZsb29yKHgpXG5cblx0IyBwcmludCBmIChNYXRoLmZsb29yIDEgKyAyMDAwMDAwICogcmFuZG9tKCkgZm9yIGkgaW4gcmFuZ2UgMjAwMDAwKVxuXHQjICNmKFs5NzkwNTc3IGZvciBpIGluIHJhbmdlKDIwMDAwMCldKVxuXHQjcHJpbnQgRGF0ZS5ub3coKSAtIHN0YXJ0LCdtcydcblxuIl19
//# sourceURL=c:\github\2021\010\coffee\app.coffee

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 10e6+1

function main() {
  const value = new Array(maxN + 1).fill(1);
  for (let i = 0; i < maxN + 1; i++) {
    value[i] = i
  }
  //
  for (let i = 2; i < maxN + 1; i++) {
    for (let j = i * i; j < maxN + 1; j += i) {
      while (value[j] % (i * i) === 0) {
        value[j] = value[j] / (i * i)
      }
    }
  }
  // console.log(value)
  var x = parseInt(readline())

  Array(parseInt(x)).fill(1).map((t, iii) => {
    // var n = parseInt(readline())
    var [n, k] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var aa = {}
    for (let i = 0; i < n; i++) {
      a[i] = value[a[i]]
    }

    var array = {}
    var ans = 0
    for (let i = 0; i < n; i++) {
      if (i === 0 || array[a[i]]) {
        ans++
        array = {}
      }
      array[a[i]] = true
    }
    // a = a.sort((a,b)=>a-b)
    // console.log(a)
    console.log(ans)

  });
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 10e6+1

function main() {
  const value = new Array(maxN + 1).fill(1);
  for (let i = 0; i < maxN + 1; i++) {
    value[i] = i
  }
  //
  for (let i = 2; i < maxN + 1; i++) {
    for (let j = i * i; j < maxN + 1; j += i) {
      if (value[j] % (i * i) === 0) {
        value[j] = value[j] / (i * i)
      }
    }
  }
  // console.log(value)
  var x = parseInt(readline())

  Array(parseInt(x)).fill(1).map((t, iii) => {
    // var n = parseInt(readline())
    var [n, k] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var aa = {}
    for (let i = 0; i < n; i++) {
      a[i] = value[a[i]]
    }

    var array = {}
    var ans = 0
    for (let i = 0; i < n; i++) {
      if (i === 0 || array[a[i]]) {
        ans++
        array = {}
      }
      array[a[i]] = true
    }
    // a = a.sort((a,b)=>a-b)
    // console.log(a)
    console.log(ans)

  });
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 10e6

function main() {
  const value = new Array(maxN + 1).fill(1);
  for (let i = 0; i < maxN + 1; i++) {
    value[i] = i
  }
  //
  for (let i = 2; i < maxN + 1; i++) {
    for (let j = i * i; j < maxN + 1; j += i) {
      if (value[j] % (i * i) === 0) {
        value[j] = value[j] / (i * i)
      }
    }
  }
  // console.log(value)
  var x = parseInt(readline())

  Array(parseInt(x)).fill(1).map((t, iii) => {
    // var n = parseInt(readline())
    var [n, k] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var aa = {}
    for (let i = 0; i < n; i++) {
      a[i] = value[a[i]]
    }

    var array = {}
    var ans = 0
    for (let i = 0; i < n; i++) {
      if (i === 0 || array[a[i]]) {
        ans++
        array = {}
      }
      array[a[i]] = true
    }
    // a = a.sort((a,b)=>a-b)
    // console.log(a)
    console.log(ans)

  });
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 30

function main() {
  const value = new Array(maxN + 1).fill(1);
  for (let i = 0; i < maxN + 1; i++) {
    value[i] = i
  }
  //
  for (let i = 2; i < maxN + 1; i++) {
    for (let j = i * i; j < maxN + 1; j += i) {
      if (value[j] % (i * i) === 0) {
        value[j] = value[j] / (i * i)
      }
    }
  }
  // console.log(value)
  var x = parseInt(readline())

  Array(parseInt(x)).fill(1).map((t, iii) => {
    // var n = parseInt(readline())
    var [n, k] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var aa = {}
    for (let i = 0; i < n; i++) {
      a[i] = value[a[i]]
    }

    var array = []
    var ans = 0
    for (let i = 0; i < n; i++) {
      if (i === 0 || array.includes(a[i])) {
        ans++
        array = []
      }
      array.push(a[i])
    }
    // a = a.sort((a,b)=>a-b)
    // console.log(a)
    console.log(ans)

  });
}