#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]]++;
//* Maintain atmost K-1 small window
while(l<=e && small.size() >= k){
small[a[l]]--;
if(small[a[l]] == 0) small.erase(a[l]);
l++;
}
//* Atmost K big window
//* Insufficient window => Expand
if(big.size() < k){
e++;
}
//* Sufficient window
else{
//* Invalid window => Keep Shrink Window
while(s<=e && big.size() > k){
big[a[s]]--;
if(big[a[s]] == 0) big.erase(a[s]);
s++;
}
//* Valid window => Compute Result && expand
//* Big window - small window
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]]++;
//* Maintain atmost K-1 small window
while(l<=e && small.size() >= k){
small[a[l]]--;
if(small[a[l]] == 0) small.erase(a[l]);
l++;
}
//* Maintain atmost K big window
while(s<=e && big.size() > k){
big[a[s]]--;
if(big[a[s]] == 0) big.erase(a[s]);
s++;
}
//* Valid window => Compute Result && expand
//* Big window - small window
ans += (l-s);
e++;
}
return ans;
}
int consistency4(int n, int k){
unordered_map<int,int> big, small;
int ans = 0;
for(int j=0, i=0, l=0; j<n; j++){
big[a[j]]++;
small[a[j]]++;
//* Maintain atmost K-1 small window
while(l<=j && small.size() >= k){
small[a[l]]--;
if(small[a[l]] == 0) small.erase(a[l]);
l++;
}
//* Maintain atmost K big window
while(i<=j && big.size() > k){
big[a[i]]--;
if(big[a[i]] == 0) big.erase(a[i]);
i++;
}
ans += (l-i);
}
return ans;
}
int practice(int n, int k){
return 0;
}
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) << " " << consistency3(n,k) << " " << consistency4(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;
}