#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define maxn 10000010
const int MOD = 1000000007;

vector<int> primes;
vector<bool> isPrime(maxn, true);

void sieve(int n = maxn - 10) {
    isPrime[0] = isPrime[1] = false;
    for (int i = 3; i * i <= n; i += 2)
        if (isPrime[i])
            for (int j = i * i; j <= n; j += 2 * i)
                isPrime[j] = false;
    primes.push_back(2);
    for (int i = 3; i <= n; i += 2)
        if (isPrime[i])primes.push_back(i);
}
unordered_map<int, int> mp;
int get(int val) {
    if (mp.count(val))return mp[val];
    int ret = 1, temp = val;
    for (auto x: primes) {
        if (x * x > val)break;
        int ct = 0;
        while (val % x == 0) {
            val /= x;
            ct++;
        }
        ct %= 2;
        if (ct)ret *= x;
    }
    if (val > 1)ret *= val;
    return mp[temp] = ret;
}

void solve() {
    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        v[i] = get(v[i]);
    }
    map<int, int> pre;
    int ct = 1;
    for (auto &i : v) {
        if (pre.count(i)) {
            pre.clear();
            ct++;
        }
        pre[i]++;
    }
    cout << ct << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    sieve();
    int t = 1;
    cin >> t;

    while (t--)
        solve();
    return 0;
}