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, …, 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?

Input

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.

The first line of each test case contains two integers n, k (1 ≤ n ≤ 2 ⋅ 10^5, k = 0).

The second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^7).

It's guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.

Output

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

Example

Input


3
5 0
18 6 2 4 1
5 0
6 8 1 24 8
1 0
1


Output


3
2
1

Note

In the first test case the division may be as follows:

  * [18, 6] 
  * [2, 4] 
  * [1]

Difficulty: MEDIUM_HARD

Solutions:
import sys
input = sys.stdin.readline

def is_Prime(i):
	if i == 2:
		return True
	if i % 2 == 0 or i == 1:
		return False
	s = int(i ** (1 / 2))
	while True:
		if s == 1:
			return True
		if i % s == 0:
			return False
		s -= 1
t = int(input())
sq = [pow(2, 2)]
for i in range(3, pow(10, 4), 2):
	if is_Prime(i):
		sq.append(pow(i, 2))
inf = pow(10, 7)
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ng = set()
	ans = 1
	for i in a:
		x = i
		for j in sq:
			if x < j:
				break
			while not x % j:
				x //= j
		if not x in ng:
			ng.add(x)
		else:
			ans += 1
			ng.clear()
			ng.add(x)
	print(ans)


from sys import stdin
input = lambda : stdin.readline().strip()
lin = lambda : list(map(int, input().split()))
iin = lambda : int(input())
main = lambda : map(int, input().split())
from math import ceil, sqrt, factorial, log
from collections import deque
from bisect import bisect_left
mod = 998244353
mod = 1000000007
N = int(sqrt(10 ** 7)) + 20
prime = [True for i in range(N + 1)]
p = 2
while p * p <= N:
	if prime[p] == True:
		for i in range(p * p, N + 1, p):
			prime[i] = False
	p += 1
x = []
for p in range(2, N + 1):
	if prime[p]:
		x.append(p)

def gcd(a, b):
	(a, b) = (max(a, b), min(a, b))
	while a % b != 0:
		(a, b) = (b, a % b)
	return b

def moduloinverse(a):
	return pow(a, mod - 2, mod)

def solve(we):
	(n, k) = main()
	l = lin()
	z = []
	ans = 0
	for i in range(n):
		j = 0
		t = 1
		q = 0
		while j < len(x) and l[i] > 1:
			if l[i] % x[j] == 0:
				q += 1
				l[i] = l[i] // x[j]
			else:
				if q != 0:
					if q % 2 != 0:
						t *= x[j]
					q = 0
				j += 1
		if q != 0:
			if q % 2 != 0:
				t *= x[j]
		t *= l[i]
		z.append(t)
	ans = 0
	s = set()
	for i in range(n):
		if z[i] in s:
			ans += 1
			s = set()
			s.add(z[i])
		else:
			s.add(z[i])
	ans += 1
	print(ans)
qwe = iin()
for _ in range(qwe):
	solve(_ + 1)


import sys
input = sys.stdin.readline
max_ = 10 ** 4
tf = [True] * (max_ + 1)
tf[0] = False
tf[1] = False
for i in range(2, int((max_ + 1) ** 0.5 + 1)):
	if not tf[i]:
		continue
	for j in range(i * i, max_ + 1, i):
		tf[j] = False
primes = []
for i in range(2, max_ + 1):
	if tf[i]:
		primes.append(i)

def main():
	(n, k) = map(int, input().split())
	alst = list(map(int, input().split()))
	ans = 1
	se = set()
	for a in alst:
		for p in primes:
			pp = p * p
			if pp > a:
				break
			while a % pp == 0:
				a //= pp
		if a in se:
			ans += 1
			se = set()
		se.add(a)
	print(ans)
for _ in range(int(input())):
	main()


import sys
import os
from math import sqrt, gcd, ceil, log, floor, sin, pi
from math import factorial as fact
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
from itertools import permutations
input = sys.stdin.readline

def read():
	return list(map(int, input().strip().split()))

def read_f():
	return list(map(float, input().strip().split()))
MOD = 10 ** 9 + 7

def lcm(arr):
	_lcm = 1
	for i in arr:
		_lcm = i * _lcm // gcd(i, _lcm)
	return _lcm

def f(n):
	res = 1
	for i in range(2, int(sqrt(n) + 1)):
		c = 0
		while n % i == 0:
			n //= i
			c += 1
		if c % 2:
			res *= i
	if n > 1:
		res *= n
	return res

def main():
	ans_ = []
	for _ in range(int(input())):
		d = set()
		(n, m) = read()
		arr = read()
		ans = 0
		for i in arr:
			need = f(i)
			if i in d or need in d:
				ans += 1
				d = set()
			d.add(need)
			d.add(i)
		if d:
			ans += 1
		ans_.append(ans)
	for i in ans_:
		print(i)
main()


import sys
input = sys.stdin.readline
from math import sqrt
from functools import lru_cache

@lru_cache(None)
def fac(x):
	ans = 1
	for i in range(2, int(sqrt(x)) + 1):
		if not x % i:
			cnt = 0
			while not x % i:
				x //= i
				cnt += 1
			if cnt % 2:
				ans *= i
	if x > 1:
		ans *= x
	return ans
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = [fac(a) for a in A]
	ans = 1
	seen = set()
	for b in B:
		if b in seen:
			seen = {b}
			ans += 1
		else:
			seen.add(b)
	print(ans)


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from functools import lru_cache

@lru_cache(None)
def mask(x):
	cnt = 0
	ans = 1
	while not x % 2:
		x //= 2
		cnt += 1
	if cnt % 2:
		ans = 2
	for i in range(3, int(x ** 0.5) + 1, 2):
		if not x % i:
			cnt = 0
			while not x % i:
				x //= i
				cnt += 1
			if cnt % 2:
				ans *= i
	if x > 1:
		ans *= x
	return ans
for _ in range(ii1()):
	(n, k) = iia()
	arr = iia()
	masks = [mask(i) for i in arr]
	ans = 1
	dic = defaultdict(int)
	for a in masks:
		if a in dic:
			dic = defaultdict(int)
			dic[a] = 1
			ans += 1
		else:
			dic[a] = 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
getcontext().prec = 25
MOD = pow(10, 9) + 7
BUFSIZE = 8192
from collections import defaultdict

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def sieve_of_eratosthenes(n):
	all_prime = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n):
		if prime[p]:
			all_prime.append(p)
	return all_prime

def prime_factors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in primes[1:]:
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l
primes = sieve_of_eratosthenes(int(math.sqrt(10000000) + 1))

def replace_num(num):
	f = prime_factors(num)
	f.sort()
	s = []
	a = 1
	for i in f:
		if s:
			if i == s[-1]:
				s.pop(-1)
			else:
				s.append(i)
		else:
			s.append(i)
	for i in s:
		a *= i
	return a
for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	for i in range(n):
		l[i] = replace_num(l[i])
	d = dict()
	ans = 1
	for i in l:
		if d.get(i, 0):
			d = {i: 1}
			ans += 1
		else:
			d[i] = 1
	print(ans)


import logging
import sys
from collections import Counter, defaultdict
from inspect import currentframe
input = sys.stdin.readline
logging.basicConfig(level=logging.DEBUG)

def dbg(*args):
	id2names = {id(v): k for (k, v) in currentframe().f_back.f_locals.items()}
	logging.debug(', '.join((id2names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args)))

def prime_factorization(n):
	i = 2
	ret = []
	while i * i <= n:
		while n % i == 0:
			ret.append(i)
			n //= i
		i += 1
	if n > 1:
		ret.append(n)
	return ret

def solve():
	ans = 1
	banned_set = set()
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for ai in a:
		pf = prime_factorization(ai)
		c = Counter(pf)
		num = 1
		for (k, v) in c.items():
			if v % 2 == 1:
				num *= k
		if num in banned_set:
			ans += 1
			banned_set = set()
			banned_set.add(num)
		else:
			banned_set.add(num)
	return ans

def main():
	t = int(input())
	for _ in range(t):
		print(solve())
main()


import sys
import math

def input():
	return sys.stdin.readline().rstrip()

def read_int_list():
	return list(map(int, input().split()))

def read_int_tuple():
	return tuple(map(int, input().split()))

def read_int():
	return int(input())
prime_table = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137]
import math
t = read_int()

def drop_square(num):
	for pm in prime_table:
		pm2 = pm ** 2
		if pm2 > num:
			return num
		while num % pm2 == 0:
			num /= pm2
	return num
for _ in range(t):
	(n, k) = read_int_list()
	a = read_int_list()
	ans = 0
	buffer = {}
	for (idx, pivot) in enumerate(a):
		pivot = drop_square(pivot)
		if pivot in buffer:
			ans += 1
			buffer = {}
		buffer[pivot] = 1
	else:
		ans += 1
	print(ans)


import sys
input = lambda : sys.stdin.readline().rstrip()

def eratosthenes_sieve(limit):
	primes = []
	is_prime = [True] * (limit + 1)
	is_prime[0] = False
	is_prime[1] = False
	for p in range(0, limit + 1):
		if not is_prime[p]:
			continue
		primes.append(p)
		for i in range(p * p, limit + 1, p):
			is_prime[i] = False
	return primes
P = eratosthenes_sieve(3162)
from functools import lru_cache

@lru_cache(maxsize=None)
def sq_fr(m):
	for p in P:
		if p ** 2 > m:
			break
		while not m % p ** 2:
			m //= p ** 2
	return m
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	ans = 1
	SF = set()
	for a in A:
		sf = sq_fr(a)
		if sf not in SF:
			SF.add(sf)
		else:
			ans += 1
			SF = {sf}
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
from collections import Counter

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small
for _ in range(int(input()) if True else 100000):
	(n, k) = map(int, input().split())
	b = list(map(int, input().split()))
	ans = 1
	st = set()
	for i in b:
		fp = prime_factors(i)
		pro = 1
		for x in fp:
			if fp[x] % 2:
				pro *= x
		if pro in st:
			ans += 1
			st = set()
			st.add(pro)
		else:
			st.add(pro)
	print(ans)


from sys import stdin
from collections import defaultdict
from copy import deepcopy
import heapq
import math
from functools import reduce

def get_prime_nums():
	lst = [2]
	for i in range(3, 10000):
		is_prime = True
		for x in lst:
			if i % x == 0:
				is_prime = False
				break
		if is_prime:
			lst.append(i)
	return lst

def get_mask(num, prime_nums):
	dv = []
	for p in prime_nums:
		c = 0
		while num % p == 0:
			c += 1
			num = num // p
		if c % 2 == 1:
			dv.append(p)
	if num != 1:
		dv.append(num)
	return ' '.join((str(_) for _ in dv))

def get_ans(n, k, lst, prime_nums):
	i = 0
	ans = 0
	o_set = set()
	while i < n:
		mask = get_mask(lst[i], prime_nums)
		if mask in o_set:
			o_set = set()
			ans += 1
		i += 1
		o_set.add(mask)
	return ans + 1
prime_nums = get_prime_nums()
t = int(stdin.buffer.readline())
for _ in range(t):
	(n, k) = map(int, stdin.buffer.readline().split())
	lst = list(map(int, stdin.buffer.readline().split()))
	print(get_ans(n, k, lst, prime_nums))


def sieve(n):
	is_prime = [True for _ in range(n + 1)]
	is_prime[1] = False
	for i in range(2, n + 1):
		if is_prime[i]:
			j = 2 * i
			while j <= n:
				is_prime[j] = False
				j += i
	table = [i for i in range(1, n + 1) if is_prime[i]]
	return table

def fact(n):
	for p in primes:
		while n % (p * p) == 0:
			n //= p * p
	return n
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import defaultdict
T = int(input())
ans = [1] * T
primes = sieve(3500)
for t in range(T):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	lis = defaultdict(lambda : False)
	for a in A:
		b = fact(a)
		if lis[b]:
			ans[t] += 1
			lis = defaultdict(lambda : False)
		lis[b] = True
print(*ans, sep='\n')


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True

def find(num):
	ans = 1
	c = 0
	while num % 2 == 0:
		c += 1
		num //= 2
	if c % 2:
		ans *= 2
	for i in range(3, int(sqrt(num)) + 1, 2):
		c = 0
		while num % i == 0:
			c += 1
			num //= i
		if c % 2:
			ans *= i
	if num > 1:
		ans *= num
	return ans
for _ in range(int(inp())):
	(n, k) = mp()
	arr = lmp()
	c = 1
	pre = {}
	for i in arr:
		rem = find(i)
		if rem in pre:
			pre = {}
			c += 1
		pre[rem] = 1
	print(c)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(i) for i in st()]

@lru_cache(None)
def give(n):
	pro = 1
	for i in range(2, int(n ** 0.5) + 1):
		curr = 0
		while n % i == 0:
			n //= i
			curr += 1
		if curr & 1:
			pro *= i
	if n > 1:
		pro *= n
	return pro
for _ in range(val()):
	(n, k) = li()
	l = li()
	ans = 0
	i = 0
	while i < n:
		ans += 1
		curr = set()
		while i < n:
			temp = give(l[i])
			if temp in curr:
				break
			curr.add(temp)
			i += 1
	print(ans)


import math
from collections import defaultdict

def primeFactors(n):
	res = []
	while n % 2 == 0:
		res.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			res.append(int(i))
			n = n / i
	if n > 2:
		res.append(int(n))
	return res
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	d = dict()
	ans = 0
	b = list(map(int, input().split()))
	res = 0
	for j in b:
		d1 = defaultdict(lambda : 0)
		req = primeFactors(j)
		for j in req:
			d1[j] += 1
		ans = 1
		for j in set(req):
			if d1[j] % 2 != 0:
				ans *= j
		if ans in d.keys():
			res += 1
			d = dict()
		d[ans] = 1
	print(res + 1)


import collections
import string
import math
import copy
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
mo = 998244353

def exgcd(a, b):
	if not b:
		return (1, 0)
	(y, x) = exgcd(b, a % b)
	y -= a // b * x
	return (x, y)

def getinv(a, m):
	(x, y) = exgcd(a, m)
	return -1 if x == 1 else x % m

def comb(n, b):
	res = 1
	b = min(b, n - b)
	for i in range(b):
		res = res * (n - i) * getinv(i + 1, mo) % mo
	return res % mo

def quickpower(a, n):
	res = 1
	while n:
		if n & 1:
			res = res * a % mo
		n >>= 1
		a = a * a % mo
	return res

def dis(a, b):
	return abs(a[0] - b[0]) + abs(a[1] - b[1])

def getpref(x):
	if x > 1:
		return x * (x - 1) >> 1
	else:
		return 0

def orafli(upp):
	primes = []
	marked = [False for i in range(upp + 3)]
	prvs = [i for i in range(upp + 3)]
	for i in range(2, upp):
		if not marked[i]:
			primes.append(i)
		for j in primes:
			if i * j >= upp:
				break
			marked[i * j] = True
			prvs[i * j] = j
			if i % j == 0:
				break
	return (primes, prvs)

def lower_ord(c: str) -> int:
	return ord(c) - 97

def upper_ord(c: str) -> int:
	return ord(c) - 65

def read_list():
	return [int(i) for i in input().split()]

def read_int():
	s = input().split()
	if len(s) == 1:
		return int(s[0])
	else:
		return map(int, s)

def ask(s):
	print(f'? {s}', flush=True)

def answer(s):
	print(f'! {s}', flush=True)

def solve():
	(n, k) = read_int()
	li = read_list()
	s = set()
	ans = 0
	for i in li:
		ti = i
		mx = 1
		l = set()
		if i < 10001:
			while prv[i] != i:
				if prv[i] not in l:
					l.add(prv[i])
				else:
					l.discard(prv[i])
				i //= prv[i]
		else:
			for j in primes:
				while i % j == 0:
					if j not in l:
						l.add(j)
					else:
						l.discard(j)
					i //= j
		if i in l:
			l.discard(i)
		else:
			l.add(i)
		sux = 1
		for ii in l:
			sux *= ii
		if sux in s:
			s = {sux}
			ans += 1
		else:
			s.add(sux)
	if s:
		ans += 1
	print(ans)
(primes, prv) = orafli(10001)
t = int(input())
for ti in range(t):
	solve()


from math import ceil, floor, log
import sys, threading
from heapq import heappush, heappop
from collections import Counter, defaultdict, deque
import bisect
input = lambda : sys.stdin.readline().strip()
c = lambda x: 10 ** 9 if x == '?' else int(x)

def rec(a, l, r, m, i, l1):
	if l == r:
		l1[l] = i
		return
	if l > r:
		return
	l1[max(m[l:r + 1], key=lambda x: a[x])] = i
	rec(a, l, max(m[l:r + 1], key=lambda x: a[x]) - 1, m, i + 1, l1)
	rec(a, max(m[l:r + 1], key=lambda x: a[x]) + 1, r, m, i + 1, l1)

class node:

	def __init__(self, x, y):
		self.a = [x, y]

	def __lt__(self, b):
		return b.a[0] < self.a[0]

	def __repr__(self):
		return str(self.a[0]) + ' ' + str(self.a[1])

def main():
	prime = [1] * 10 ** 5
	p = []
	for i in range(2, 10 ** 5):
		if prime[i]:
			for j in range(i * i, 10 ** 5, i):
				prime[j] = 0
			p.append(i)
	for _ in range(int(input())):
		(n, k) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		s = set()
		ans = 1
		for m in a:
			i = m
			j = 0
			t = 1
			for j in range(10 ** 5):
				k = 0
				while i % p[j] == 0:
					i //= p[j]
					k += 1
				if k % 2 == 1:
					t *= p[j]
				if p[j] * p[j] > i:
					if i > 2:
						t *= i
					break
			if t in s:
				ans += 1
				s = set()
			s.add(t)
		print(ans)
main()


from io import BytesIO, IOBase
import sys, os
inpl = lambda : list(map(int, input().split()))
inpm = lambda : map(int, input().split())
inpi = lambda : int(input())
inp = lambda : input()
(rev, ra, l) = (reversed, range, len)
P = print
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys, operator, math, operator
from collections import Counter
ar = []

def p_s(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	for i in ra(n + 1):
		if prime[i]:
			ar.append(i)
pre = [0] * (10 ** 7 + 1)

def prime_factor(n):
	if pre[n] == 0:
		i = 0
		val = 1
		t = n
		while ar[i] * ar[i] <= n and n > 1:
			c = 0
			while n % ar[i] == 0:
				c += 1
				n /= ar[i]
			c = c % 2
			val = int(val * ar[i] ** c)
			i += 1
		if n > 1:
			val *= int(n)
		pre[t] = val
		return val
	return pre[n]
tc = inpi()
while tc:
	(n, k) = inpm()
	li = inpl()
	p_s(10 ** 4)
	arr = []
	omap = {}
	val = prime_factor(li[0])
	omap[val] = 1
	arr.append(omap)
	c = 1
	for i in ra(1, n):
		val = prime_factor(li[i])
		if val in arr[-1]:
			temp = {}
			temp[val] = 1
			c += 1
			arr.append(temp)
		else:
			arr[-1][val] = 1
	P(l(arr))
	tc -= 1


import sys
import math
from collections import defaultdict, Counter, deque
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	cur = set()
	ans = 1
	for j in a:
		s = []
		c = 0
		while j % 2 == 0:
			j //= 2
			c += 1
		c %= 2
		if c:
			s.append(2)
			c = 0
		for k in range(3, int(math.sqrt(j)) + 1, 2):
			while j % k == 0:
				c += 1
				j //= k
			c %= 2
			if c:
				s.append(k)
				c = 0
		if j > 2:
			s.append(j)
		s = tuple(s)
		if s in cur:
			ans += 1
			cur = set()
		cur.add(s)
	print(ans)


from collections import Counter

def findprime(x):
	d = Counter()
	while x % 2 == 0:
		x //= 2
		d[2] += 1
	for i in range(3, int(x ** 0.5) + 1):
		while x % i == 0:
			d[i] += 1
			x //= i
	if x > 1:
		d[x] += 1
	se = []
	for i in d:
		if d[i] % 2 == 1:
			se.append(i)
	return tuple(se)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = 0
	vis = set()
	for i in range(n):
		f = arr[i]
		c = findprime(f)
		if c in vis:
			ans += 1
			vis = set()
		vis |= {c}
	if len(vis) > 0:
		ans += 1
	print(ans)


NN = 4000
isPrime = [True] * (NN + 1)
isPrime[1] = False
i = 2
primes = []
while i * i <= NN:
	if isPrime[i]:
		for j in range(i * i, NN + 1, i):
			isPrime[j] = False
	i += 1
primes = []
for i in range(2, NN + 1):
	if isPrime[i]:
		primes.append(i)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = 1
	s = set()
	for a in arr:
		pi = 0
		need = 1
		while a > 1 and pi < len(primes):
			picnt = 0
			while a % primes[pi] == 0:
				a /= primes[pi]
				picnt += 1
			if picnt % 2 == 1:
				need *= primes[pi]
			pi += 1
		if a > 1:
			need *= a
		if need in s:
			ans += 1
			s = set()
			s.add(need)
		else:
			s.add(need)
	print(ans)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	ans = 1
	ct = 0
	while n % 2 == 0:
		n = n // 2
		ct += 1
	if ct & 1:
		ans *= 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		ct = 0
		while n % i == 0:
			n = n // i
			ct += 1
		if ct & 1:
			ans *= i
	if n > 2:
		ans *= n
	return ans

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	(n, k) = mapin()
	a = [int(x) for x in input().split()]
	for i in range(n):
		a[i] = primeFactors(a[i])
	dd = set()
	ans = 0
	for i in range(n):
		if a[i] not in dd:
			dd.add(a[i])
		else:
			ans += 1
			dd = set()
			dd.add(a[i])
	if len(dd) > 0:
		ans += 1
	dd = set()
	ans2 = 0
	for i in range(n):
		if a[n - i - 1] not in dd:
			dd.add(a[n - i - 1])
		else:
			ans2 += 1
			dd = set()
			dd.add(a[n - i - 1])
	if len(dd) > 0:
		ans2 += 1
	print(min(ans, ans2))


import sys
input = sys.stdin.readline
import math
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for j in range(n):
		if a[j] % 2 == 0:
			while a[j] % 4 == 0:
				a[j] = a[j] // 4
		for l in range(3, int(math.sqrt(a[j])) + 1):
			if a[j] % l == 0:
				while a[j] % (l * l) == 0:
					a[j] = a[j] // (l * l)
	s = set()
	c = 1
	for j in range(n):
		if a[j] in s:
			c = c + 1
			s.clear()
			s.add(a[j])
		else:
			s.add(a[j])
	print(c)


import math
import sys
import collections
import bisect
import heapq
from functools import lru_cache

class Sieve:

	def __init__(self, n):
		self.factors = [0] * (n + 1)
		self.primes = []
		self.primeset = set()
		for i in range(2, n + 1):
			if self.factors[i] == 0:
				self.factors[i] = i
				self.primes.append(i)
				self.primeset.add(i)
			for p in self.primes:
				if i * p <= n:
					self.factors[i * p] = p

	def isPrime(self, x):
		return x in self.primeset

	def factorize(self, x):
		arr = []
		while x > 1:
			arr.append(self.factors[x])
			x //= self.factors[x]
		return arr

@lru_cache(None)
def factorize(x):
	res = []
	while x != 1:
		for i in range(2, int(x ** 0.5) + 1):
			if x % i == 0:
				res.append(i)
				x = x // i
				break
		else:
			res.append(x)
			break
	return res
testcases = int(sys.stdin.readline())
for _ in range(testcases):
	arr = list(map(int, sys.stdin.readline().strip().split()))
	n = arr[0]
	k = arr[1]
	arr = list(map(int, sys.stdin.readline().strip().split()))
	res = 1
	s = set()
	curr = []
	for i in arr:
		f = factorize(i)
		d = collections.Counter(f)
		curr = 1
		for key in d:
			curr += d[key] % 2 * key
		if curr in s:
			res += 1
			s = set()
		s.add(curr)
	print(res)


import math
from collections import defaultdict

def primes(n):
	prod = 1
	sq = int(math.sqrt(n))
	for div in range(2, sq + 1):
		c = 0
		while n != 1 and n % div == 0:
			c += 1
			n //= div
		if c % 2 != 0:
			prod *= div
	if n != 1:
		prod *= n
	return prod
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	nl = []
	d = defaultdict(int)
	for i in l:
		if i not in d:
			cur = primes(i)
			d[i] = cur
		else:
			cur = d[i]
		nl.append(cur)
	seen = set()
	c = 1
	for i in nl:
		if i not in seen:
			seen.add(i)
		else:
			c += 1
			seen = set()
			seen.add(i)
	print(c)


import sys
input = sys.stdin.readline
x = 3200
import math
L = math.floor(math.sqrt(x))
Primelist = [i for i in range(x + 1)]
Primelist[1] = 0
for i in Primelist:
	if i > L:
		break
	if i == 0:
		continue
	for j in range(2 * i, x + 1, i):
		Primelist[j] = 0
Primes = [Primelist[j] for j in range(x + 1) if Primelist[j] != 0]
D = [p * p for p in Primes]
t = int(input())
for tests in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	for i in range(n):
		for d in D:
			while A[i] % d == 0:
				A[i] //= d
			if d > A[i]:
				break
	NOW = set()
	ANS = 0
	for a in A:
		if a in NOW:
			ANS += 1
			NOW = {a}
		else:
			NOW.add(a)
	print(ANS + 1)


import sys, os, io
import math
from collections import defaultdict
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def fun(n):
	ans = 1
	cnt = 0
	while n % 2 == 0:
		cnt += 1
		n = n / 2
	if cnt % 2 == 1:
		ans *= 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		cnt = 0
		while n % i == 0:
			cnt += 1
			n = n / i
		if cnt % 2 == 1:
			ans *= i
	if n > 2:
		ans *= n
	return int(ans)
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [fun(i) for i in a]
	ans = 0
	i = 0
	while i < n:
		ans += 1
		vis = set()
		while i < n:
			if b[i] in vis:
				break
			vis.add(b[i])
			i += 1
	print(ans)


T = int(input())
r = 1
prime = [2]
for i in range(3, 4 * 10 ** 3, 2):
	flag = False
	if i % 2 == 0:
		continue
	for j in range(3, int(i ** 0.5) + 1, 2):
		if i % j == 0:
			flag = True
			break
	if not flag:
		prime.append(i)

def primefactor(num):
	index = 0
	output = []
	while num >= prime[index] ** 2:
		times = 0
		while num % prime[index] == 0:
			num = num // prime[index]
			times += 1
		if times & 1:
			output.append(prime[index])
		index += 1
	if num > 1:
		output.append(num)
	return tuple(output)
while r <= T:
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = 1
	fact = {}
	for i in range(n):
		num = arr[i]
		factnum = primefactor(num)
		if factnum in fact:
			fact = {factnum: 1}
			ans += 1
		else:
			fact[factnum] = 1
	print(ans)
	r += 1


import time

def nr():
	return int(input())

def nrs():
	return [int(i) for i in input().split()]
N = 3162
p = [1] * N
for i in range(2, N):
	if p[i]:
		for j in range(2 * i, N, i):
			p[j] = 0
p2 = [c * c for c in range(2, N) if p[c]]

def f(a):
	ans = 1
	kl = set()
	hash = {}
	for r0 in a:
		if r0 not in hash:
			r = r0
			for q in p2:
				if r < q:
					break
				while r % q == 0:
					r = r // q
			hash[r0] = r
		else:
			r = hash[r0]
		if r in kl:
			ans += 1
			kl = set()
		kl.add(r)
	print(ans)
for _ in range(nr()):
	(_, _) = nrs()
	f(nrs())


import sys, getpass
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
M9 = 10 ** 9 + 7
MAXINT = sys.maxsize
OFFLINE_TEST = getpass.getuser() == 'hkmac'

def log(*args):
	if OFFLINE_TEST:
		print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)

def solve(*args):
	if OFFLINE_TEST:
		log('----- solving ------')
		log(*args)
		log('----- ------- ------')
	return solve_(*args)

def read_matrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def read_strings(rows):
	return [input().strip() for _ in range(rows)]
primes = []
LARGE = int(10 ** 3.5) + 10
factors = [[] for _ in range(LARGE + 5)]
for i in range(2, LARGE):
	if not factors[i]:
		primes.append(i)
		for j in range(i, LARGE, i):
			factors[j].append(i)
factors = [tuple(x) for x in factors]

def factorize(x):
	res = []
	for p in primes:
		cur = 0
		while x % p == 0:
			x = x // p
			cur += 1
		if cur % 2:
			res.append(p)
	if x == 1:
		return tuple(res)
	return tuple(res + [x])

def solve_(lst, k):
	assert k == 0
	res = 1
	cur = set()
	for x in lst:
		xfact = factorize(x)
		if xfact in cur:
			res += 1
			cur = set()
			cur.add(xfact)
		else:
			cur.add(xfact)
	return res
for case_num in range(int(input())):
	(_, k) = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	res = solve(lst, k)
	print(res)


import sys
input = sys.stdin.readline
p = [2, 3]
i = 5
while i * i < 10000000:
	pr = 1
	for x in p:
		if i % x == 0:
			pr = 0
			break
	if pr:
		p += [i]
	i += 2
for f in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s = set()
	ans = 1
	for x in a:
		prs = []
		for pr in p:
			nb = 0
			while x % pr == 0:
				x //= pr
				nb += 1
			if nb % 2:
				prs += [pr]
		if x > 1:
			prs += [x]
		prs = tuple(prs)
		if prs in s:
			ans += 1
			s = set()
		s.add(prs)
	print(ans)


d = {}
mask = {}
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	for ele in A:
		if ele in d:
			continue
		c = {}
		x = ele
		for i in range(2, int(ele ** 0.5) + 2):
			if ele % i == 0:
				c[i] = 0
				while ele % i == 0:
					ele //= i
					c[i] += 1
					c[i] %= 2
		if ele != 1:
			c[ele] = 1
		d[x] = c
	B = []
	for ele in A:
		cur = 1
		if ele not in mask:
			for val in d[ele]:
				cur *= val ** d[ele][val]
			mask[ele] = cur
		B.append(mask[ele])
	s = set()
	cnt = 1
	for ele in B:
		if ele in s:
			cnt += 1
			s = set()
		s.add(ele)
	print(cnt)


from sys import stdin, stdout
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import *
input = stdin.readline
prin = stdout.write
from random import sample
from collections import Counter, deque
from math import sqrt, ceil, log2, gcd
mod = 10 ** 9 + 7

def f(arr, i, j, d, dist):
	if i == j:
		return
	nn = max(arr[i:j])
	for tl in range(i, j):
		if arr[tl] == nn:
			dist[tl] = d
			f(arr, i, tl, d + 1, dist)
			f(arr, tl + 1, j, d + 1, dist)

def ps(n):
	cp = 0
	lk = 0
	arr = {}
	cc = 0
	ans = 1
	while n % 2 == 0:
		n = n // 2
		lk += 1
		cc = 1
	if lk % 2 == 1:
		ans *= 2
	for ps in range(3, ceil(sqrt(n)) + 1, 2):
		lk = 0
		cc = 0
		while n % ps == 0:
			n = n // ps
			cc = 1
			lk += 1
		if lk % 2 == 1:
			ans *= ps
	if n != 1:
		ans *= n
	return ans

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def factorials(n, r):
	slr = n
	dpr = r
	qlr = 1
	qs = 1
	mod = 10 ** 9 + 7
	for ip in range(n - r + 1, n + 1):
		qlr = qlr * ip % mod
	for ij in range(1, r + 1):
		qs = qs * ij % mod
	ans = qlr * modInverse(qs) % mod
	return ans

def modInverse(b):
	qr = 10 ** 9 + 7
	return pow(b, qr - 2, qr)
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def power(arr):
	listrep = arr
	subsets = []
	for i in range(2 ** len(listrep)):
		subset = []
		for k in range(len(listrep)):
			if i & 1 << k:
				subset.append(listrep[k])
		subsets.append(subset)
	return subsets

def pda(n):
	list = []
	for i in range(1, int(sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				list.append(i)
			else:
				list.append(n // i)
				list.append(i)
	return list

def dis(xa, ya, xb, yb):
	return sqrt((xa - xb) ** 2 + (ya - yb) ** 2)

def ii():
	return int(input())

def ilist():
	return [int(x) for x in input().strip().split()]

def out(array: list) -> str:
	array = [str(x) for x in array]
	return ' '.join(array)

def islist():
	return list(map(str, input().split().rstrip()))

def outfast(arr: list) -> str:
	ss = ''
	for ip in arr:
		ss += str(ip) + ' '
	return prin(ss)

def kk(n):
	kp = 0
	while n % 2 == 0:
		n = n // 2
		kp += 1
	if n == 1:
		return [True, kp]
	else:
		return [False, 0]
t = int(input())
for jj in range(t):
	(n, k) = ilist()
	arr = ilist()
	jp = set()
	count = 1
	for i in range(n):
		kk = ps(arr[i])
		if kk in jp:
			count += 1
			jp = set()
			jp.add(kk)
		else:
			jp.add(kk)
	prin(str(count) + '\n')