#include <bits/stdc++.h>
using namespace std;
#define int              long long int
#define double           long double


const int M = 1000000007;
const int N = 3e5+9;
const int INF = 2e9+1;
const int MAXN = 100000;
const int LINF = 2000000000000000001;

//_ ***************************** START Below *******************************



vector<int> a;

//* Count of Exactly k = (Atmost k ) - (Atmost k-1 )

int atmostK(int n, int k){
    unordered_map<int,int> mp;
    int ans = 0;
    int s = 0, e = 0;
    while(e<n){
        mp[a[e]]++;
        if(mp.size() <= k){
            ans += (e-s+1);
            e++;
        }
        else{
            while(s<=e && mp.size() > k){
                mp[a[s]]--;
                if(mp[a[s]] == 0) mp.erase(a[s]);
                s++;
            }
            ans += (e-s+1);
            e++;
        }
    }
    return ans;
}

int consistency1(int n, int k){
	
	return atmostK(n, k) - atmostK(n, k-1);
	
}




//* Template 1

int consistency2(int n, int k){
	
    unordered_map<int,int> big, small;
    int ans = 0;
    int s = 0, l = 0, e = 0;
    
    while(e<n){
        //* Calculate State
        big[a[e]]++;
        small[a[e]]++;
        
        //* Invalid Small window => Shrink 
        while(l<=e && small.size() >= k){
            small[a[l]]--;
            if(small[a[l]] == 0) small.erase(a[l]);
            l++;
        }
		
		//* Insufficient Big window => Expand Window
        if(big.size() < k){
            e++;
        }
        //* Valid Big window =>  Compute result + Expand window
        else if(big.size() == k){
            ans += (l-s);
            e++;
        }
        else{
        	//* Invalid Big Window => Shrink window
            while(s<=e && big.size() > k){
                big[a[s]]--;
                if(big[a[s]] == 0) big.erase(a[s]);
                s++;
            }
            //* Valid Big window => Compute Result && Expand
            ans += (l-s);
            e++;
        }
    }
    return ans;
}




//* Template 2

int consistency3(int n, int k){
	
    unordered_map<int,int> big, small;
    int ans = 0;
    int s = 0, l = 0, e = 0;
    
    while(e<n){
        //* Calculate State
        big[a[e]]++;
        small[a[e]]++;
        
        //* Invalid Small window => Shrink 
        while(l<=e && small.size() >= k){
            small[a[l]]--;
            if(small[a[l]] == 0) small.erase(a[l]);
            l++;
        }
		
		//* Insufficient Big window => Expand Window
        if(big.size() < k){
            e++;
        }
        else{
        	//* Invalid Big Window => Shrink window (cache invalidation)
            while(s<=e && big.size() > k){
                big[a[s]]--;
                if(big[a[s]] == 0) big.erase(a[s]);
                s++;
            }
            //* Valid Big window => Compute Result && Expand
            ans += (l-s);
            e++;
        }
    }
    return ans;
}









int practice(int n, int k){
	
	int ans = 0;
	
	unordered_map<int,int> big, small;
	
	int s = 0, e = 0;
	int l = 0;
	
	while(e<n){
		big[a[e]]++;
		small[a[e]]++;
		
		while(l<=e && small.size() >= k){
			small[a[l]]--;
			if(small[a[l]] == 0) small.erase(a[l]);
			l++;
		}
		
		if(big.size() < k){
			e++;
		}
		else{
			while(s<=e && big.size() > k){
				big[a[s]]--;
				if(big[a[s]] == 0) big.erase(a[s]);
				s++;
			}
			
			ans += l-s;
			e++;
		}
	}
	
	return ans;
	
}




void solve() {

	int n, k;
	cin >> n >> k;
	a.resize(n);
	for(int i=0; i<n; i++) cin >> a[i];

	// cout << consistency1(n, k) << " " << consistency2(n,k) <<  " " << consistency2(n,k) << endl;
	
	cout << consistency1(n, k) << " -> " << practice(n, k) << endl;
	
}





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

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}