#include <bits/stdc++.h>

#define NMAX 200005
using namespace std;

long long v[NMAX];
map<long long, bool > mp;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    int t;
    cin >> t;

    while(t--)
    {
        int n, k;
        cin >> n >> k;

        for(int i = 1; i <= n; ++i)
            cin >> v[i];

        mp.clear();
        int cnt = 0;
        for(int i = 1; i <= n; ++i){
            int d = 2;
            long long rem = 1;
            while(d * d <= v[i]){
                int exp = 0;
                while(v[i] % d == 0){
                    ++exp;
                    v[i] /= d;
                }

                if(exp > 0){
                    if(exp % 2)
                        rem *= d;
                }
                ++d;
            }

            if(v[i] > 1)
                rem *= v[i];
            if(rem == 1)
                rem = 0;
            if(mp.find(rem) == mp.end())
                mp[rem] = 1;
            else {
                ++cnt;
                mp.clear();
                mp[rem] = 1;
            }
        }
        ++cnt;
        cout << cnt << '\n';
    }
    return 0;
}
