#include <bits/stdc++.h>
using namespace std;
#define int              long long int
#define double           long double
#define print(a)         for(auto x : a) cout << x << " "; cout << endl


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

inline int power(int a, int b, int mod=M) {
    int x = 1;
    a %= mod;
    while (b) {
        if (b & 1) x = (x * a) % mod; 
        a = (a * a) % mod;
        b >>= 1;
    }
    return x;
}


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



string a;

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

int atmostK(int n, int k){
	
	vector<int> mp(26);
	int size = 0;
	
	int ans = 0;
	int s = 0, e = 0;
	
	while(e<n){
	    mp[a[e]-'a']++;
	    if(mp[a[e]-'a'] == 1) size++;
	    
	    if(size < k){
	    	ans += (e-s+1);
	        e++;
	    }
	    else{
	        while(s<=e && size > k){
	            mp[a[s]-'a']--;
	            if(mp[a[s] - 'a'] == 0) size--;
	            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){
	
	vector<int> big(26), small(26);
	int bigSize = 0, smallSize = 0;
	
	int ans = 0;
	int s = 0, e = 0;
	int l = 0;
	
	while(e<n){
		
	    big[a[e]-'a']++;
	    if(big[a[e]-'a'] == 1) bigSize++;
	    
	    small[a[e]-'a']++;
	    if(small[a[e]-'a'] == 1) smallSize++;
	    
	    while(l<=e && smallSize >= k){
	        small[a[l]-'a']--;
	        if(small[a[l]-'a'] == 0) smallSize--;
	        l++;
	    }
	    
	    if(bigSize < k){
	        e++;
	    }
	    else{
	        while(s<=e && bigSize > k){
	            big[a[s]-'a']--;
	            if(big[a[s] - 'a'] == 0) bigSize--;
	            s++;
	        }
	        ans += (l-s);
	        e++;
	    }
	}
	
	return ans;

}







//* Template 2
int consistency3(int n, int k){
        
    vector<int> big(26), sm(26);
    int bigSz = 0, smSz = 0;
    
    int ans = 0;
    
    for(int j=0, i=0, l=0; j<n; j++){
    	
        big[a[j]-'a']++;
        if(big[a[j] - 'a'] == 1) bigSz++;
        
        sm[a[j]-'a']++;
        if(sm[a[j] - 'a'] == 1) smSz++;
        
        
        while(l<=j && smSz >= k){
            sm[a[l]-'a']--;
            if(sm[a[l] - 'a'] == 0) smSz--;
            l++;
        }
        
        while(i<=j && bigSz > k){
            big[a[i] - 'a']--;
            if(big[a[i] - 'a'] == 0) bigSz--;
            i++;
        }
        
        ans += l-i;
        
    }
    return ans;
}
















int practice(int n, int k){
	
	return 0;	
}




void solve() {

	int k;
	cin >> k >> a;
	int n = a.size();

	cout << consistency1(n, k) << " " << consistency2(n,k) <<  " " << consistency3(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;
}