#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;

#define sc scanf
#define ls rt << 1
#define rs ls | 1
#define Min(x, y) x = min(x, y)
#define Max(x, y) x = max(x, y)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define MEM(x, b) memset(x, b, sizeof(x))
#define lowbit(x) ((x) & -(x))
#define P2(x) ((x) * (x))

typedef long long ll;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 100;
const int INF = 0x3f3f3f3f;
inline ll fpow(ll a, ll b){ ll r = 1, t = a; while (b){ if (b & 1)r = (r*t) % MOD; b >>= 1; t = (t*t) % MOD; }return r; }

int p[MAXN], n;

int main()
{
	int T; cin >> T;
	while (T--) {
		sc("%d", &n);
		int g = 1, s = 1, b = 1;
		for (int i = 1; i <= n; i++) sc("%d", &p[i]);
		int tot = n / 2;
		int ans1 = p[1], j = 2;
		for (int i = 2; i <= n; i++) {
			if (p[i] == ans1) g++;
			else { j = i; break; }
		}
		int ans2 = p[j], k = j + 1;
		for (int i = j + 1; i <= n; i++) {
			if (p[i] == ans2) s++;
			else {
				if (s > g) { k = i; break; }
				else ans2 = p[i], s++;
			}
		}
		if (s <= g || s + g >= tot) { printf("0 0 0\n"); continue; }
		int ans3 = p[k];
		for (int i = k + 1; i <= n; i++) {
			if (p[i] == ans3) b++;
			else {
				if (b <= g || g + s + b < tot) ans3 = p[i], b++;
				else {
					if (g + s + b == tot) break;
					else {
						int cnt = p[i - 1]; b--;
						for (int j = i - 2; j >= 1; j--) {
							if (p[j] != cnt) break;
							b--;
						}
						break;
					}
				}
			}
		}
		if (g + s + b > tot || g >= b || g >= s) printf("0 0 0\n");
		else printf("%d %d %d\n", g, s, b);
	}
	return 0;  // 改数组大小!!!
}


//#define LOCAL
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <bitset>
#include <iterator>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <map>
#include <ctime>
#define fore(i, a, b) for(ll i = (a), _b = (b); i < (_b); i++)
#define fort(i, a, b) for(ll i = (a), _b = (b); i <= (_b); i++)
#define ford(i, a, b) for(ll i = (a), _b = (b); i >= (_b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
using namespace std;

template<class T> bool mini(T &a, T b){return a > b ? (a = b, 1) : 0; }
template<class T> bool maxi(T &a, T b){return a < b ? (a = b, 1) : 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const int maxN = 4e5 + 5;

int t,n,m;
ll a[maxN],nxt[maxN];

int main(){
    #ifdef LOCAL
        freopen("taskC.INP","r",stdin);
    //    freopen("taskC.OUT","w",stdout);
    #endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while(t--){
        cin >> n;
        fort(i,1,n){
            cin >> a[i];
        }
        if(n < 6){
            cout << "0 0 0\n";
            continue;
        }
        m = n >> 1;
        while(m >= 1 && a[m] == a[m + 1])
            m--;
        if(m < 5){
            cout << "0 0 0\n";
            continue;
        }
        a[n] = n;
        ford(i,n - 1,1)
            if(a[i] > a[i + 1])
                nxt[i] = i;
            else
                nxt[i] = nxt[i + 1];
        if(nxt[1] < m){
            if((nxt[1] << 1 | 1) < m &&
                nxt[nxt[1] << 1 | 1] < m &&
                m - nxt[nxt[1] << 1 | 1] > nxt[1]){
                cout << nxt[1] << ' '
                     << nxt[nxt[1] << 1 | 1] - nxt[1] << ' '
                     << m - nxt[nxt[1] << 1 | 1] << '\n';
            }else
                cout << "0 0 0\n";
        }else{
            cout << "0 0 0\n";
        }
    }
    return 0;
}


//#define LOCAL
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <bitset>
#include <iterator>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <map>
#include <ctime>
#define fore(i, a, b) for(ll i = (a), _b = (b); i < (_b); i++)
#define fort(i, a, b) for(ll i = (a), _b = (b); i <= (_b); i++)
#define ford(i, a, b) for(ll i = (a), _b = (b); i >= (_b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
using namespace std;

template<class T> bool mini(T &a, T b){return a > b ? (a = b, 1) : 0; }
template<class T> bool maxi(T &a, T b){return a < b ? (a = b, 1) : 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const int maxN = 4e5 + 5;

int t,n,m;
ll a[maxN],nxt[maxN];

int main(){
    #ifdef LOCAL
        freopen("taskC.INP","r",stdin);
    //    freopen("taskC.OUT","w",stdout);
    #endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while(t--){
        cin >> n;
        fort(i,1,n){
            cin >> a[i];
        }
        if(n < 6){
            cout << "0 0 0\n";
            continue;
        }
        m = n >> 1;
        while(m >= 1 && a[m] == a[m + 1])
            m--;
        if(m < 3){
            cout << "0 0 0\n";
            continue;
        }
        ford(i,m,1)
            if(a[i] > a[i + 1])
                nxt[i] = i;
            else
                nxt[i] = nxt[i + 1];
        if(nxt[1] < m){
            if(nxt[nxt[1] << 1 | 1] < m){
                cout << nxt[1] << ' '
                     << nxt[nxt[1] << 1 | 1] - nxt[1] << ' '
                     << m - nxt[nxt[1] << 1 | 1] << '\n';
            }else
                cout << "0 0 0\n";
        }else{
            cout << "0 0 0\n";
        }
    }
    return 0;
}


//#define LOCAL
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <bitset>
#include <iterator>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <map>
#include <ctime>
#define fore(i, a, b) for(ll i = (a), _b = (b); i < (_b); i++)
#define fort(i, a, b) for(ll i = (a), _b = (b); i <= (_b); i++)
#define ford(i, a, b) for(ll i = (a), _b = (b); i >= (_b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
using namespace std;

template<class T> bool mini(T &a, T b){return a > b ? (a = b, 1) : 0; }
template<class T> bool maxi(T &a, T b){return a < b ? (a = b, 1) : 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const int maxN = 4e5 + 5;

int t,n,m;
ll a[maxN],nxt[maxN];

int main(){
    #ifdef LOCAL
        freopen("taskC.INP","r",stdin);
    //    freopen("taskC.OUT","w",stdout);
    #endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while(t--){
        cin >> n;
        fort(i,1,n){
            cin >> a[i];
        }
        if(n < 6){
            cout << "0 0 0\n";
            continue;
        }
        m = n >> 1;
        while(m >= 1 && a[m] == a[m + 1])
            m--;
        if(m < 3){
            cout << "0 0 0\n";
            continue;
        }
        ford(i,m,1)
            if(a[i] > a[i + 1])
                nxt[i] = i;
            else
                nxt[i] = nxt[i + 1];
        if(nxt[1] < m){
            if(nxt[nxt[1] << 1 | 1] < m && m - nxt[nxt[1] << 1 | 1] > nxt[1]){
                cout << nxt[1] << ' '
                     << nxt[nxt[1] << 1 | 1] - nxt[1] << ' '
                     << m - nxt[nxt[1] << 1 | 1] << '\n';
            }else
                cout << "0 0 0\n";
        }else{
            cout << "0 0 0\n";
        }
    }
    return 0;
}


//#define LOCAL
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <bitset>
#include <iterator>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <map>
#include <ctime>
#define fore(i, a, b) for(ll i = (a), _b = (b); i < (_b); i++)
#define fort(i, a, b) for(ll i = (a), _b = (b); i <= (_b); i++)
#define ford(i, a, b) for(ll i = (a), _b = (b); i >= (_b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
using namespace std;

template<class T> bool mini(T &a, T b){return a > b ? (a = b, 1) : 0; }
template<class T> bool maxi(T &a, T b){return a < b ? (a = b, 1) : 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const int maxN = 4e5 + 5;

int t,n,m;
ll a[maxN],nxt[maxN];

int main(){
    #ifdef LOCAL
        freopen("taskC.INP","r",stdin);
    //    freopen("taskC.OUT","w",stdout);
    #endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while(t--){
        cin >> n;
        fort(i,1,n){
            cin >> a[i];
        }
        if(n < 6){
            cout << "0 0 0\n";
            continue;
        }
        m = n >> 1;
        while(m >= 1 && a[m] == a[m + 1])
            m--;
        if(m < 6){
            cout << "0 0 0\n";
            continue;
        }
        ford(i,m,1)
            if(a[i] > a[i + 1])
                nxt[i] = i;
            else
                nxt[i] = nxt[i + 1];
        if(nxt[1] < m){
            if((nxt[1] << 1 | 1) < m && nxt[nxt[1] << 1 | 1] < m && m - nxt[nxt[1] << 1 | 1] > nxt[1]){
                cout << nxt[1] << ' '
                     << nxt[nxt[1] << 1 | 1] - nxt[1] << ' '
                     << m - nxt[nxt[1] << 1 | 1] << '\n';
            }else
                cout << "0 0 0\n";
        }else{
            cout << "0 0 0\n";
        }
    }
    return 0;
}


//#define LOCAL
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <bitset>
#include <iterator>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <map>
#include <ctime>
#define fore(i, a, b) for(ll i = (a), _b = (b); i < (_b); i++)
#define fort(i, a, b) for(ll i = (a), _b = (b); i <= (_b); i++)
#define ford(i, a, b) for(ll i = (a), _b = (b); i >= (_b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
using namespace std;

template<class T> bool mini(T &a, T b){return a > b ? (a = b, 1) : 0; }
template<class T> bool maxi(T &a, T b){return a < b ? (a = b, 1) : 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const int maxN = 4e5 + 5;

int t,n,m;
ll a[maxN],nxt[maxN];

int main(){
    #ifdef LOCAL
        freopen("taskC.INP","r",stdin);
    //    freopen("taskC.OUT","w",stdout);
    #endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while(t--){
        cin >> n;
        fort(i,1,n){
            cin >> a[i];
        }
        if(n < 6){
            cout << "0 0 0\n";
            continue;
        }
        m = n >> 1;
        while(m >= 1 && a[m] == a[m + 1])
            m--;
        if(m < 6){
            cout << "0 0 0\n";
            continue;
        }
        a[n] = n;
        ford(i,n - 1,1)
            if(a[i] > a[i + 1])
                nxt[i] = i;
            else
                nxt[i] = nxt[i + 1];
        if(nxt[1] < m){
            if((nxt[1] << 1 | 1) < m &&
                nxt[nxt[1] << 1 | 1] < m &&
                m - nxt[nxt[1] << 1 | 1] > nxt[1]){
                cout << nxt[1] << ' '
                     << nxt[nxt[1] << 1 | 1] - nxt[1] << ' '
                     << m - nxt[nxt[1] << 1 | 1] << '\n';
            }else
                cout << "0 0 0\n";
        }else{
            cout << "0 0 0\n";
        }
    }
    return 0;
}


//#define LOCAL
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <bitset>
#include <iterator>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <map>
#include <ctime>
#define fore(i, a, b) for(ll i = (a), _b = (b); i < (_b); i++)
#define fort(i, a, b) for(ll i = (a), _b = (b); i <= (_b); i++)
#define ford(i, a, b) for(ll i = (a), _b = (b); i >= (_b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
using namespace std;

template<class T> bool mini(T &a, T b){return a > b ? (a = b, 1) : 0; }
template<class T> bool maxi(T &a, T b){return a < b ? (a = b, 1) : 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const int maxN = 4e5 + 5;

int t,n,m;
ll a[maxN],nxt[maxN];

int main(){
    #ifdef LOCAL
        freopen("taskC.INP","r",stdin);
    //    freopen("taskC.OUT","w",stdout);
    #endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while(t--){
        cin >> n;
        fort(i,1,n){
            cin >> a[i];
        }
        if(n < 6){
            cout << "0 0 0\n";
            continue;
        }
        m = n >> 1;
        while(m >= 1 && a[m] == a[m + 1])
            m--;
        if(m < 3){
            cout << "0 0 0\n";
            continue;
        }
        ford(i,m,1)
            if(a[m] > a[m + 1])
                nxt[i] = i;
            else
                nxt[i] = nxt[i + 1];
        if(nxt[1] < m){
            if(nxt[nxt[1] << 1 | 1] < m){
                cout << nxt[1] << ' '
                     << nxt[nxt[1] << 1 | 1] - nxt[1] << ' '
                     << m - nxt[nxt[1] << 1 | 1] << '\n';
            }else
                cout << "0 0 0\n";
        }else{
            cout << "0 0 0\n";
        }
    }
    return 0;
}


#include<iostream>
using namespace std;

int main(){
    int m,n,lim;
    cin>>m;
    while(m--){
        cin>>n;
        int sc[n];
        for (int i =0;i<n;i++)
            cin>>sc[i];
        lim=n/2;
        while (sc[lim-1]==sc[lim])
            lim--;
        int o=0,g=1,s=0,c=1;
        while(sc[g]==sc[g-1]){
            g++;
        }
        while(c<=g)
            c++;
        while(sc[lim-c]==sc[lim-c-1])
            c++;
        if(lim-g-c<=g){
            cout<<"0 0 0"<<endl;
            continue;
        }
         cout<<g<<' '<<lim-c-g<<' '<<c<<endl;
    }
}


#include<iostream>
using namespace std;

int main(){
    int m,n,lim;
    cin>>m;
    while(m--){
        cin>>n;
        int sc[n];
        for (int i =0;i<n;i++)
            cin>>sc[i];
        lim=n/2;
        while (sc[lim-1]==sc[lim])
            lim--;
        int o=0,g=1,s=0,c=1;
        while(sc[g]==sc[g-1]){
            g++;
        }
        while(c<=g||sc[lim-c]==sc[lim-c-1])
            c++;
        if(lim-g-c<=g){
            cout<<"0 0 0"<<endl;
            continue;
        }
         cout<<g<<' '<<lim-c-g<<' '<<c<<endl;
    }
}


#include<iostream>
using namespace std;

int main(){
    int m,n,lim;
    cin>>m;
    while(m--){
        cin>>n;
        int sc[n];
        for (int i =0;i<n;i++)
            cin>>sc[i];
        lim=n/2;
        while (sc[lim-1]==sc[lim])
            lim--;
        int g=1,c;
        while(sc[g]==sc[g-1]){
            g++;
        }
        c=g+1;
        while(sc[lim-c]==sc[lim-c-1])
            c++;
        if(lim-g-c<=g){
            cout<<"0 0 0"<<endl;
            continue;
        }
         cout<<g<<' '<<lim-c-g<<' '<<c<<endl;
    }
}


#include<iostream>
using namespace std;

int main(){
    int m,n,lim;
    cin>>m;
    while(m--){
        cin>>n;
        int sc[n];
        for (int i =0;i<n;i++)
            cin>>sc[i];
        lim=n/2;
        while (sc[lim-1]==sc[lim])
            lim--;
        int o=0,g=1,s=0,c=0;
        while(sc[g]==sc[g-1]){
            g++;
        }
        while(g>=s){
            s++;
        while(sc[g+s]==sc[g+s-1]){
            s++;
        }        }
        while(g>=c){
            c++;
        while(sc[g+s+c]==sc[g+s+c-1]){
            c++;
        }        }
        if(g+s+c>lim){
            cout<<"0 0 0"<<endl;
            continue;
        }
         while(g+s+c!=lim)
                c++;
         cout<<g<<' '<<s<<' '<<c<<endl;
    }
}


#include<iostream>
using namespace std;

int main(){
    int m,n,lim;
    cin>>m;
    while(m--){
        cin>>n;
        int sc[n];
        for (int i =0;i<n;i++)
            cin>>sc[i];
        lim=n/2;
        while (sc[lim-1]==sc[lim])
            lim--;
        int g=1,c;
        while(sc[g]==sc[g-1]){
            g++;
        }
        c=g+1
        while(sc[lim-c]==sc[lim-c-1])
            c++;
        if(lim-g-c<=g){
            cout<<"0 0 0"<<endl;
            continue;
        }
         cout<<g<<' '<<lim-c-g<<' '<<c<<endl;
    }
}


#include<iostream>
using namespace std;

int main(){
    int m,n,lim;
    cin>>m;
    while(m--){
        cin>>n;
        int sc[400000];
        for (int i =0;i<n;i++)
            cin>>sc[i];
        lim=n/2;
        while (lim>0&&sc[lim-1]==sc[lim])
            lim--;
        int g=1,c;
        while(g<n-1&&sc[g]==sc[g-1]){
            g++;
        }
        c=g+1;
        while(lim-g-c>g&&sc[lim-c]==sc[lim-c-1])
            c++;
        if(lim-g-c<=g){
            cout<<"0 0 0"<<endl;
            continue;
        }
         cout<<g<<' '<<lim-c-g<<' '<<c<<endl;
    }
}


#include<iostream>
using namespace std;

int main(){
    int m,n,lim;
    cin>>m;
    while(m--){
        cin>>n;
        int sc[n];
        for (int i =0;i<n;i++)
            cin>>sc[i];
        lim=n/2;
        while (sc[lim-1]==sc[lim])
            lim--;
        int o=0,g=1,s=0,c=0;
        while(sc[g]==sc[g-1]){
            g++;
        }
        while(g>s){
            s++;
        while(sc[g+s]==sc[g+s-1]){
            s++;
        }        }
        while(g>c){
            c++;
        while(sc[g+s+c]==sc[g+s+c-1]){
            c++;
        }        }
        if(g+s+c>lim){
            cout<<"0 0 0"<<endl;
            continue;
        }
         while(g+s+c!=lim)
                c++;
         cout<<g<<' '<<s<<' '<<c<<endl;
    }
}


#include<iostream>
using namespace std;

int main(){
    int m,n,lim;
    cin>>m;
    while(m--){
        cin>>n;
        int sc[n];
        for (int i =0;i<n;i++)
            cin>>sc[i];
        lim=n/2;
        while (sc[lim-1]==sc[lim])
            lim--;
        int g=1,c;
        while(sc[g]==sc[g-1]){
            g++;
        }
        c=g+1;
        while(sc[lim-c]==sc[lim-c-1]&&!lim-g-c<=g)
            c++;
        if(lim-g-c<=g){
            cout<<"0 0 0"<<endl;
            continue;
        }
         cout<<g<<' '<<lim-c-g<<' '<<c<<endl;
    }
}


#include <queue>
#include <cstdio>

using namespace std;

int main()
{
    int t;
    scanf("%d", &t);
    while(t--) {
	queue<int> Q;
	int n, prev, tmp, l(1), r(1);
	scanf("%d", &n);
	scanf("%d", &tmp);
	prev = tmp;
	while(r < n) {
	    while(r < n && tmp == prev) {
		++r;
		prev = tmp;
		scanf("%d", &tmp);
	    }
	    prev = tmp;
	    Q.push(r - l);
	    l = r;
	}

	int g(0), s(0), b(0);
	if(!Q.empty()) {
	    g = Q.front();
	    Q.pop();
	}
	while(!Q.empty() && s <= g) {
	    s += Q.front();
	    Q.pop();
	}
	while(!Q.empty() && g + s + b + Q.front() <= n/2) {
	    b += Q.front();
	    Q.pop();
	}

	if(g >= s || g >= b) {
	    g = s = b = 0;
	}
	printf("%d %d %d\n", g, s, b);
    }
}


#include <queue>
#include <cstdio>

using namespace std;

int main()
{
    int t;
    scanf("%d", &t);
    while(t--) {
	queue<int> Q;
	int n, prev, tmp, l(1), r(1);
	scanf("%d", &n);
	scanf("%d", &tmp);
	prev = tmp;
	while(r < n) {
	    while(r < n && tmp == prev) {
		++r;
		prev = tmp;
		scanf("%d", &tmp);
	    }
	    prev = tmp;
	    Q.push(r - l);
	    l = r;
	}

	int g, s(0), b(0);
	g = Q.front();
	Q.pop();
	while(!Q.empty() && s <= g) {
	    s += Q.front();
	    Q.pop();
	}
	while(!Q.empty() && g + s + b + Q.front() <= n/2) {
	    b += Q.front();
	    Q.pop();
	}

	if(g >= s || g >= b) {
	    g = s = b = 0;
	}
	printf("%d %d %d\n", g, s ,b);
    }
}


#include <cstdio>

using namespace std;

int main()
{
    int t;
    scanf("%d", &t);
    while(t--) {
	int n, prev, tmp, i(1), g(0), s(0), b(0);
	scanf("%d", &n);
	scanf("%d", &tmp);
	if(n == 1) {
	    printf("0 0 0\n");
	    continue;
	}
	prev = tmp;
	while(i < n && tmp == prev) {
	    ++i;
	    prev = tmp;
	    scanf("%d", &tmp);
	}
	g = i - 1;
	prev = tmp;
	while(i < n && (i <= 2*g + 1 || tmp == prev)) {
	    ++i;
	    prev = tmp;
	    scanf("%d", &tmp);
	}
	s = i - g - 1;
	prev = tmp;
	int end = i;
	while(i < n) {
	    while(i < n && tmp == prev) {
		++i;
		prev = tmp;
		scanf("%d", &tmp);
	    }
	    prev = tmp;
	    if(i <= n/2 + 1) {
		end = i;
	    } else break;
	}
	b = end - g - s - 1;
	if(g == 0 || s == 0 || b == 0 || g >= s || g >= b || g + s + b > n/2) {
	    g = s = b = 0;
	}
	printf("%d %d %d\n", g, s, b);
	char c;
	if(i < n -1) while((c = getchar()) != '\n'){}
    }
}


#include <cstdio>

using namespace std;

int main()
{
    int t;
    scanf("%d", &t);
    while(t--) {
	int n, prev, tmp, i(1), g(0), s(0), b(0);
	scanf("%d", &n);
	scanf("%d", &tmp);
	if(n == 1) {
	    printf("0 0 0\n");
	    continue;
	}
	prev = tmp;
	while(i < n && tmp == prev) {
	    ++i;
	    prev = tmp;
	    scanf("%d", &tmp);
	}
	g = i - 1;
	prev = tmp;
	while(i < n && (i <= 2*g + 1 || tmp == prev)) {
	    ++i;
	    prev = tmp;
	    scanf("%d", &tmp);
	}
	s = i - g - 1;
	prev = tmp;
	int end = i;
	while(true) {
	    while(i < n && tmp == prev) {
		++i;
		prev = tmp;
		scanf("%d", &tmp);
	    }
	    prev = tmp;
	    if(i <= n/2 + 1) {
		end = i;
	    } else break;
	}
	b = end - g - s - 1;
	if(g == 0 || s == 0 || b == 0 || g >= s || g >= b || g + s + b > n/2) {
	    g = s = b = 0;
	}
	printf("%d %d %d\n", g, s, b);
	char c;
	if(i < n -1) while((c = getchar()) != '\n'){}
    }
}


#include <bits/stdc++.h>
#define fr(i,n) for(int i = 0; i < n; i++)
#define int long long
#define pb push_back
#define pii pair<int,int>

using namespace std;

main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		int half = n / 2;
		int a[n];
		fr(i,n) cin >> a[i];

		if(n <= 3)
		{
			cout << "0 0 0 \n";
			continue;
		}
		int l = 1;
		int kn = n;
		n = n / 2;

		while(a[l] == a[0])
		{
			l++;
		}
		int r = n - 1;
		while(a[r] == a[n])
		{
			r--;
			n--;
		}
		while(a[r] == a[n - 1])
		{
			r--;
		}
		if(r <= l)
		{
			cout << "0 0 0\n";
			continue;
		}

		if(l >= (n - 1) / 2)
		{
			cout << "0 0 0 \n";
			continue;
		}

		if(l < (n - r - 1))
		{
			cout << l << " " << r - l + 1 << " " << n - r - 1 << endl;
			continue;
		}
		while(l >= (n - r - 1))
		{
		  r--;
		}
		while(a[r - 1] == a[r])
		{
			r--;
		}

		if(r <= l)
		{
			cout << "0 0 0\n";
			continue;
		}
		if(l >= (r-l + 1) || l >= (n - r - 1))
		{
			cout << "0 0 0 \n";
			continue;
		}
		cout << l << " " << r - l << " " << n - r << endl;
	}
}


#include <bits/stdc++.h>
#define fr(i,n) for(int i = 0; i < n; i++)
#define int long long
#define pb push_back
#define pii pair<int,int>

using namespace std;

main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		int a[n];
		fr(i,n) cin >> a[i];
		int cnt = n / 2;
		while(cnt > 0 && a[cnt] == a[cnt - 1]) cnt--;

		if(cnt == 0)
		{
			puts("0 0 0");
			continue;
		}
		int g = 1;
		while(g < cnt && a[g] == a[g - 1])
		{
			g++;
		}
		int s = g + 1;
		while(g + s < cnt && a[g + s - 1] == a[g + s])
		{
			s++;
		}
		int b = cnt - s - g;
		if(b > g)
		{
			cout << g << " " << s << " "<< b << endl;
		} else
		{
			puts("0 0 0");
		}
	}
}


#include <bits/stdc++.h>
#define fr(i,n) for(int i = 0; i < n; i++)
#define int long long
#define pb push_back
#define pii pair<int,int>

using namespace std;

main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		int half = n / 2;
		int a[n];
		fr(i,n) cin >> a[i];

		if(n <= 3)
		{
			cout << "0 0 0 \n";
			continue;
		}
		int l = 1;
		int kn = n;
		n = n / 2;

		while(a[l] == a[0])
		{
			l++;
		}
		int r = n - 1;
		while(a[r] == a[n])
		{
			r--;
			n--;
		}
		while(a[r] == a[n - 1])
		{
			r--;
		}
		if(r <= l)
		{
			cout << "0 0 0\n";
			continue;
		}
		if(l >= (r-l) || l >= (n - r))
		{
			cout << "0 0 0 \n";
			continue;
		}
		if(l >= (n - 1) / 2)
		{
			cout << "0 0 0 \n";
			continue;
		}
		if(n  - r - 1 > l)
		{

			cout << l << " " << r - l + 1 << " " << n  - r - 1 << endl;
			continue;
		}
		while(n  - r - 1 <= l)
		{
			r--;
		}
		while(a[r - 1] == a[r])
		{
			r--;
		}
		if(r <= l)
		{
			cout << "0 0 0\n";
			continue;
		}
		if(l >= (r-l) || l >= (n - r))
		{
			cout << "0 0 0 \n";
			continue;
		}
		cout <<l << " " << r - l << " " << n - r << endl;

	}
}


#include <bits/stdc++.h>
#define fr(i,n) for(int i = 0; i < n; i++)
#define int long long
#define pb push_back
#define pii pair<int,int>

using namespace std;

main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		int half = n / 2;
		int a[n];
		fr(i,n) cin >> a[i];

		if(n <= 3)
		{
			cout << "0 0 0 \n";
			continue;
		}
		int l = 1;
		int kn = n;
		n = n / 2;

		while(a[l] == a[0])
		{
			l++;
		}
		int r = n - 1;
		while(a[r] == a[n])
		{
			r--;
			n--;
		}
		while(a[r] == a[n - 1])
		{
			r--;
		}
		if(r <= l)
		{
			cout << "0 0 0\n";
			continue;
		}
		if(l >= (r-l) || l >= (n - r))
		{
			cout << "0 0 0 \n";
			continue;
		}
		cout << l << " " << r - l << " " << n - r << endl;

		if(l >= (n - 1) / 2)
		{
			cout << "0 0 0 \n";
			continue;
		}

	}
}


#include <bits/stdc++.h>
#define fr(i,n) for(int i = 0; i < n; i++)
#define int long long
#define pb push_back
#define pii pair<int,int>

using namespace std;

main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		int half = n / 2;
		int a[n];
		fr(i,n) cin >> a[i];

		if(n <= 3)
		{
			cout << "0 0 0 \n";
			continue;
		}
		int l = 1;
		int kn = n;
		n = n / 2;

		while(a[l] == a[0])
		{
			l++;
		}
		int r = n - 1;
		while(a[r] == a[n])
		{
			r--;
			n--;
		}
		while(a[r] == a[n - 1])
		{
			r--;
		}
		if(r <= l)
		{
			cout << "0 0 0\n";
			continue;
		}
		if(l >= (r-l) || l >= (n - r))
		{
			cout << "0 0 0 \n";
			continue;
		}
		if(l >= (n - 1) / 2)
		{
			cout << "0 0 0 \n";
			continue;
		}
		if(n  - r - 1 > l)
		{
			cout << l << " " << r - l + 1 << " " << n  - r - 1 << endl;
			continue;
		}
		while(n  - r - 1 <= l)
		{
			r--;
		}
		while(a[r - 1] == a[r])
		{
			r--;
		}
		if(r <= l)
		{
			cout << "0 0 0\n";
			continue;
		}
		if(l >= (r-l) || l >= (n - r))
		{
			cout << "0 0 0 \n";
			continue;
		}
		cout <<l << " " << r - l + 1 << " " << n - r - 1 << endl;

	}
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int T, n, x;
	cin >> T;
	for(int t = 0; t < T; t++)
	{
		cin >> n;
		vector<int> p, v;
		bool res = true;
		for(int i = 0; i < n; i++)
		{
			cin >> x;
			p.push_back(x);
		}
		v.push_back(0);	// padding
		v.push_back(1);
		for(int i = 1; i < n; i++)
		{
			if(p[i] == p[i-1])
			{
				v.back()++;
			}
			else
			{
				v.push_back(v.back() + 1);
			}
		}
		int g = 0, s = 0, b = 0;
		int gt = 0, st = 0, bt = 0, si = 0, i = 0;
		const int gi = 1;
		for(i = v.size() - 1; i >= 3; i--)
		{
			if(v[i] > n/2)
			{
				continue;
			}
			gt = v[gi];
			for(si = gi + 1; si < i; si++)
			{
				st = v[si] - gt;
				if(st > gt)
				{
					break;
				}
			}
			if(st <= gt)
			{
				break;
			}
			bt = v[i] - gt - st;
			if(bt > gt)
			{
				g = gt;
				s = st;
				b = bt;
			}
			break;
		}
		cout << g << ' ' << s << ' ' << b << '\n';
	}
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int T, n, x;
	cin >> T;
	for(int t = 0; t < T; t++)
	{
		cin >> n;
		vector<int> p, v;
		bool res = true;
		for(int i = 0; i < n; i++)
		{
			cin >> x;
			p.push_back(x);
		}
		v.push_back(0);	// padding
		v.push_back(1);
		for(int i = 1; i < n; i++)
		{
			if(p[i] == p[i-1])
			{
				v.back()++;
			}
			else
			{
				v.push_back(v.back() + 1);
			}
		}
		int g = 0, s = 0, b = 0;
		int gt = 0, st = 0, bt = 0, si = 0, i = 0;
		const int gi = 1;
		for(i = v.size() - 1; i > 0; i--)
		{
			if(v[i] > n/2)
			{
				continue;
			}

			if(v[gi] >= v[i]/3)
			{
				break;
			}
			gt = v[gi];
			for(si = gi + 1; si < i; si++)
			{
				st = v[si] - v[gi];
				if(st > v[gi])
				{
					break;
				}
			}
			bt = v[i] - gt - st;
			if(bt > gt)
			{
				g = gt;
				s = st;
				b = bt;
				break;
			}
		}
		cout << g << ' ' << s << ' ' << b << '\n';
	}
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int T, n, x;
	cin >> T;
	for(int t = 0; t < T; t++)
	{
		cin >> n;
		vector<int> p, v;
		bool res = true;
		for(int i = 0; i < n; i++)
		{
			cin >> x;
			p.push_back(x);
		}
		v.push_back(0);	// padding
		v.push_back(1);
		for(int i = 1; i < n; i++)
		{
			if(p[i] == p[i-1])
			{
				v.back()++;
			}
			else
			{
				v.push_back(v.back() + 1);
			}
		}
		int g = 0, s = 0, b = 0;
		int gt = 0, st = 0, bt = 0, si = 0, i = 0;
		const int gi = 1;
		for(i = v.size() - 1; i > 3; i--)
		{
			if(v[i] > n/2)
			{
				continue;
			}
			gt = v[gi];
			for(si = gi + 1; si < i; si++)
			{
				st = v[si] - gt;
				if(st > gt)
				{
					break;
				}
			}
			if(st <= gt)
			{
				break;
			}
			bt = v[i] - gt - st;
			if(bt > gt)
			{
				g = gt;
				s = st;
				b = bt;
			}
			break;
		}
		cout << g << ' ' << s << ' ' << b << '\n';
	}
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int T, n, x;
	cin >> T;
	for(int t = 0; t < T; t++)
	{
		cin >> n;
		vector<int> p, v;
		bool res = true;
		for(int i = 0; i < n; i++)
		{
			cin >> x;
			p.push_back(x);
		}
		v.push_back(0);	// padding
		v.push_back(1);
		for(int i = 1; i < n; i++)
		{
			if(p[i] == p[i-1])
			{
				v.back()++;
			}
			else
			{
				v.push_back(v.back() + 1);
			}
		}
		int g = 0, s = 0, b = 0;
		int gt = 0, st = 0, bt = 0, si = 0, i = 0;
		const int gi = 1;
		for(i = v.size() - 1; i > 0; i--)
		{
			if(v[i] > n/2)
			{
				continue;
			}

			if(v[gi] >= v[i]/3)
			{
				break;
			}
			gt = v[gi];
			for(si = gi + 1; si < i; si++)
			{
				st = v[si] - gt;
				if(st > gt)
				{
					break;
				}
			}
			if(st <= gt)
			{
				break;
			}
			bt = v[i] - gt - st;
			if(bt > gt)
			{
				g = gt;
				s = st;
				b = bt;
				break;
			}
		}
		cout << g << ' ' << s << ' ' << b << '\n';
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define lowbit(x) x&(-x)
using namespace std;
const int maxn=500000+10;
int a[maxn],cnt,sum;
int b[maxn],c[maxn];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		a[0]=-1; cnt=-1; sum=0;
		for(int i=1; i<=n; i++){
			scanf("%d",&a[i]);
			if(a[i]!=a[i-1]){
				cnt++; b[cnt]=sum; sum=1;
				if(cnt){
					c[cnt]=c[cnt-1]+b[cnt];
				}
			}
			else{
				sum++;
			}
		}
		b[++cnt]=sum;
		/*for(int i=1; i<=cnt; i++){
			printf("%d ",b[i]);
		}
		puts("");*/
		int Max_id; sum=0;
		for(int i=1; i<=cnt; i++){
			if(sum+b[i]>n/2){
				break;
			}
			else{
				sum+=b[i]; Max_id=i;
			}
		}
		if(n/2<3 || cnt<=3){
			puts("0 0 0"); continue;
		}
		bool flag=false; int j=Max_id;
		for(int i=1; i<=Max_id; i++){
			if(c[i]>c[Max_id]/3){
				break;
			}
			while(c[Max_id]-c[j-1]<=c[i] && j>i) j--;
			if(j==i) break;
			if(c[j-1]-c[i]>c[i]){
				flag=true;
				printf("%d %d %d\n",c[i],c[j-1]-c[i],c[Max_id]-c[j-1]);
				break;
			}
			if(flag) break;
		}
		if(!flag){
			puts("0 0 0");
		}
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define lowbit(x) x&(-x)
using namespace std;
const int maxn=500000+10;
int a[maxn],cnt,sum;
int b[maxn],c[maxn];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		a[0]=-1; cnt=-1; sum=0;
		for(int i=1; i<=n; i++){
			scanf("%d",&a[i]);
			if(a[i]!=a[i-1]){
				cnt++; b[cnt]=sum; sum=1;
				if(cnt){
					c[cnt]=c[cnt-1]+b[cnt];
				}
			}
			else{
				sum++;
			}
		}
		b[++cnt]=sum;
		/*for(int i=1; i<=cnt; i++){
			printf("%d ",b[i]);
		}
		puts("");*/
		int Max_id; sum=0;
		for(int i=1; i<=cnt; i++){
			if(sum+b[i]>n/2){
				break;
			}
			else{
				sum+=b[i]; Max_id=i;
			}
		}
		if(n/2<3 || cnt<3){
			puts("0 0 0"); continue;
		}
		bool flag=false; int j=Max_id;
		for(int i=1; i<=Max_id; i++){

			while(c[Max_id]-c[j-1]<=c[i] && j>i+1) j--;
			if(j==i+1) break;
			if(c[j-1]-c[i]>c[i]){
				flag=true;
				printf("%d %d %d\n",c[i],c[j-1]-c[i],c[Max_id]-c[j-1]);
				break;
			}
			if(flag) break;
		}
		if(!flag){
			puts("0 0 0");
		}
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define lowbit(x) x&(-x)
using namespace std;
const int maxn=500000+10;
int a[maxn],cnt,sum;
int b[maxn],c[maxn];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		a[0]=-1; cnt=-1; sum=0;
		for(int i=1; i<=n; i++){
			scanf("%d",&a[i]);
			if(a[i]!=a[i-1]){
				cnt++; b[cnt]=sum; sum=1;
				if(cnt){
					c[cnt]=c[cnt-1]+b[cnt];
				}
			}
			else{
				sum++;
			}
		}
		b[++cnt]=sum;
		/*for(int i=1; i<=cnt; i++){
			printf("%d ",b[i]);
		}
		puts("");*/
		int Max_id; sum=0;
		for(int i=1; i<=cnt; i++){
			if(sum+b[i]>n/2){
				break;
			}
			else{
				sum+=b[i]; Max_id=i;
			}
		}
		if(n/2<3 || cnt<3){
			puts("0 0 0"); continue;
		}
		bool flag=false; int j=Max_id;
		for(int i=1; i<=Max_id; i++){
			if(c[i]>c[Max_id]/3){
				break;
			}
			while(c[Max_id]-c[j-1]<=c[i] && j>i+1) j--;
			if(j==i+1) break;
			if(c[j-1]-c[i]>c[i]){
				flag=true;
				printf("%d %d %d\n",c[i],c[j-1]-c[i],c[Max_id]-c[j-1]);
				break;
			}
			if(flag) break;
		}
		if(!flag){
			puts("0 0 0");
		}
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define lowbit(x) x&(-x)
using namespace std;
const int maxn=1000000+10;
int a[maxn],cnt,sum;
int b[maxn],c[maxn];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		memset(b,0,sizeof(b));
		memset(c,0,sizeof(c));
		a[0]=-1; cnt=-1; sum=0;
		for(int i=1; i<=n; i++){
			scanf("%d",&a[i]);
			if(a[i]!=a[i-1]){
				cnt++; b[cnt]=sum; sum=1;
				if(cnt){
					c[cnt]=c[cnt-1]+b[cnt];
				}
			}
			else{
				sum++;
			}
		}
		b[++cnt]=sum;
		int Max_id=0; sum=0;
		for(int i=1; i<=cnt; i++){
			if(sum+b[i]>n/2){
				break;
			}
			else{
				sum+=b[i]; Max_id=i;
			}
		}
		if(n/2<3 || Max_id<3){
			puts("0 0 0"); continue;
		}
		bool flag=false; int j=Max_id;
		while(c[Max_id]-c[j-1]<=c[1] && j>2) j--;
		if(j==2) continue;
		if(c[j-1]-c[1]>c[1]){
			flag=true;
			printf("%d %d %d\n",c[1],c[j-1]-c[1],c[Max_id]-c[j-1]);
		}
		if(!flag){
			puts("0 0 0");
		}
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define lowbit(x) x&(-x)
using namespace std;
const int maxn=500000+10;
int a[maxn],cnt,sum;
int b[maxn],c[maxn];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		a[0]=-1; cnt=-1; sum=0;
		for(int i=1; i<=n; i++){
			scanf("%d",&a[i]);
			if(a[i]!=a[i-1]){
				cnt++; b[cnt]=sum; sum=1;
				if(cnt){
					c[cnt]=c[cnt-1]+b[cnt];
				}
			}
			else{
				sum++;
			}
		}
		b[++cnt]=sum;
		/*for(int i=1; i<=cnt; i++){
			printf("%d ",b[i]);
		}
		puts("");*/
		int Max_id; sum=0;
		for(int i=1; i<=cnt; i++){
			if(sum+b[i]>n/2){
				break;
			}
			else{
				sum+=b[i]; Max_id=i;
			}
		}
		if(n/2<3 || cnt<3){
			puts("0 0 0"); continue;
		}
		bool flag=false;
		for(int k=Max_id; k>=3; k--){
			int j=Max_id;
			for(int i=1; i<=k; i++){
				if(c[i]>c[k]/3){
					break;
				}
				while(c[k]-c[j-1]<=c[i] && j>i+1) j--;
				if(j==i+1) break;
				if(c[j-1]-c[i]>c[i]){
					flag=true;
					printf("%d %d %d\n",c[i],c[j-1]-c[i],c[k]-c[j-1]);
					break;
				}
				if(flag) break;
			}
			if(flag) break;
		}
		if(!flag){
			puts("0 0 0");
		}
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define lowbit(x) x&(-x)
using namespace std;
const int maxn=500000+10;
int a[maxn],cnt,sum;
int b[maxn],c[maxn];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		a[0]=-1; cnt=-1; sum=0;
		for(int i=1; i<=n; i++){
			scanf("%d",&a[i]);
			if(a[i]!=a[i-1]){
				cnt++; b[cnt]=sum; sum=1;
				if(cnt){
					c[cnt]=c[cnt-1]+b[cnt];
				}
			}
			else{
				sum++;
			}
		}
		b[++cnt]=sum;
		/*for(int i=1; i<=cnt; i++){
			printf("%d ",b[i]);
		}
		puts("");*/
		int Max_id; sum=0;
		for(int i=1; i<=cnt; i++){
			if(sum+b[i]>n/2){
				break;
			}
			else{
				sum+=b[i]; Max_id=i;
			}
		}
		bool flag=false; int j=Max_id-1;
		for(int i=1; i<=Max_id; i++){
			if(c[i]>c[Max_id]/3){
				break;
			}
			while(c[Max_id]-c[j-1]<c[i] && j>i) j--;
			if(j==i) break;
			if(c[j-1]-c[i]>=c[i]){
				flag=true;
				printf("%d %d %d\n",c[i],c[j-1]-c[i],c[Max_id]-c[j-1]);
				break;
			}
			if(flag) break;
		}
		if(!flag){
			puts("0 0 0");
		}
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define lowbit(x) x&(-x)
using namespace std;
const int maxn=500000+10;
int a[maxn],cnt,sum;
int b[maxn],c[maxn];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		a[0]=-1; cnt=-1; sum=0;
		for(int i=1; i<=n; i++){
			scanf("%d",&a[i]);
			if(a[i]!=a[i-1]){
				cnt++; b[cnt]=sum; sum=1;
				if(cnt){
					c[cnt]=c[cnt-1]+b[cnt];
				}
			}
			else{
				sum++;
			}
		}
		b[++cnt]=sum;
		/*for(int i=1; i<=cnt; i++){
			printf("%d ",b[i]);
		}
		puts("");*/
		int Max_id; sum=0;
		for(int i=1; i<=cnt; i++){
			if(sum+b[i]>n/2){
				break;
			}
			else{
				sum+=b[i]; Max_id=i;
			}
		}
		if(n/2<3 || cnt<3){
			puts("0 0 0"); continue;
		}
		bool flag=false;
		for(int k=Max_id; k>=3; k--){
			int j=Max_id;
			for(int i=1; i<=k-2; i++){
				if(c[i]>c[k]/3){
					break;
				}
				while(c[k]-c[j-1]<=c[i] && j>i+1) j--;
				if(j==i+1) break;
				if(c[j-1]-c[i]>c[i]){
					flag=true;
					printf("%d %d %d\n",c[i],c[j-1]-c[i],c[k]-c[j-1]);
					break;
				}
				if(flag) break;
			}
			if(flag) break;
		}
		if(!flag){
			puts("0 0 0");
		}
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define lowbit(x) x&(-x)
using namespace std;
const int maxn=1000000+10;
int a[maxn],cnt,sum;
int b[maxn],c[maxn];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		a[0]=-1; cnt=-1; sum=0;
		c[0]=0;
		for(int i=1; i<=n; i++){
			scanf("%d",&a[i]);
			if(a[i]!=a[i-1]){
				cnt++; b[cnt]=sum; sum=1;
				if(cnt){
					c[cnt]=c[cnt-1]+b[cnt];
				}
			}
			else{
				sum++;
			}
		}
		b[++cnt]=sum;
		int Max_id=0; sum=0;
		for(int i=1; i<=cnt; i++){
			if(sum+b[i]>n/2){
				break;
			}
			else{
				sum+=b[i]; Max_id=i;
			}
		}
		if(n/2<3 || Max_id<3){
			puts("0 0 0"); continue;
		}
		bool flag=false; int j=Max_id;
		while(c[Max_id]-c[j-1]<=c[1] && j>2) j--;
		if(j!=2 && c[j-1]-c[1]>c[1]){
			flag=true;
			printf("%d %d %d\n",c[1],c[j-1]-c[1],c[Max_id]-c[j-1]);
		}
		if(!flag){
			puts("0 0 0");
		}
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define lowbit(x) x&(-x)
using namespace std;
const int maxn=500000+10;
int a[maxn],cnt,sum;
int b[maxn],c[maxn];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		a[0]=-1; cnt=-1; sum=0;
		for(int i=1; i<=n; i++){
			scanf("%d",&a[i]);
			if(a[i]!=a[i-1]){
				cnt++; b[cnt]=sum; sum=1;
				if(cnt){
					c[cnt]=c[cnt-1]+b[cnt];
				}
			}
			else{
				sum++;
			}
		}
		b[++cnt]=sum;
		/*for(int i=1; i<=cnt; i++){
			printf("%d ",b[i]);
		}
		puts("");*/
		int Max_id; sum=0;
		for(int i=1; i<=cnt; i++){
			if(sum+b[i]>n/2){
				break;
			}
			else{
				sum+=b[i]; Max_id=i;
			}
		}
		if(n/2<3 || cnt<=3){
			puts("0 0 0"); continue;
		}
		bool flag=false; int j=Max_id;
		for(int i=1; i<=Max_id; i++){
			if(c[i]>c[Max_id]/3){
				break;
			}
			while(c[Max_id]-c[j-1]<c[i] && j>i) j--;
			if(j==i) break;
			if(c[j-1]-c[i]>=c[i]){
				flag=true;
				printf("%d %d %d\n",c[i],c[j-1]-c[i],c[Max_id]-c[j-1]);
				break;
			}
			if(flag) break;
		}
		if(!flag){
			puts("0 0 0");
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 501000;
int a[N];
int main()
{
    int T;
    cin >> T;
    for (;T--;)
    {
        int n;
        cin >> n;
        int num = 0;
        int lastx = -1;
        a[0] = 0;
        for (int i = 1;  i <= n; i++)
        {
           int x;
           cin >> x;
           if (x == lastx) a[num]++;
           else a[++num] = 1;
           lastx = x;
        }
        int p = 0;
        int sum = 0;
        int sum1 = 0;
        int i;
        for (i = 1; i <= num; i++)
        {
             if (sum + a[i] > n/2) break;
             sum += a[i];
        }
        if (num < 3) p = 1;
        i--;
        int j;
        if (i < 3) p = 1;
        else
        {
            for (j = 2; j <= i; j++)
            {
                sum1 += a[j];
                if (sum1 > a[1]) break;
            }
        }
        if (j >= i || sum-a[1]-sum1 < a[1]) p = 1;
        if (p == 1)
        {
            cout << "0 0 0"<<endl;
        }
        else
        {
             cout << a[1] << " " << sum1 <<" "<< sum - a[1] - sum1 << endl;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
const int N = 501000;
int a[N];
int main()
{
    int T;
    cin >> T;
    for (;T--;)
    {
        int n;
        cin >> n;
        int num = 0;
        int lastx = -1;
        a[0] = 0;
        for (int i = 1;  i <= n; i++)
        {
           int x;
           cin >> x;
           if (x == lastx) a[num]++;
           else a[++num] = 1;
           lastx = x;
        }
        int p = 0;
        int sum = 0;
        int sum1 = 0;
        int i;
        for (i = 1; i <= num; i++)
        {
             if (sum + a[i] <= n/2)
             sum += a[i];
             else break;
        }
        if (num < 3) p = 1;
        int j;
        if (i < 3) p = 1;
        else
        {
            for (j = 2; j < i; j++)
            {
                sum1 += a[j];
                if (sum1 > a[1]) break;
            }
        }
        if (sum1 < a[1] || sum-a[1]-sum1 < a[1]) p = 1;
        if (p == 1)
        {
            cout << "0 0 0"<<endl;
        }
        else
        {
             cout << a[1] << " " << sum1 <<" "<< sum - a[1] - sum1 << endl;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
const int N = 501000;
int a[N];
int main()
{
    int T;
    cin >> T;
    for (;T--;)
    {
        int n;
        cin >> n;
        int num = 0;
        int lastx = -1;
        a[0] = 0;
        for (int i = 1;  i <= n; i++)
        {
           int x;
           cin >> x;
           if (x == lastx) a[num]++;
           else a[++num] = 1;
           lastx = x;
        }
        int p = 0;
        int sum = 0;
        int i;
        for (i = 1; i <= num; i++)
        {
             if (sum + a[i] > n/2) break;
             sum += a[i];
        }
        if (num < 3) p = 1;
        i--;
        if (i < 3) p = 1;
        else if (sum - a[2] - a[1] < a[1] && sum - a[i] -a[1] < a[1]) p = 1;
        if (p == 1)
        {
            cout << "0 0 0"<<endl;
        }
        else
        {
             cout << a[1] << " " << a[2] <<" " << sum - a[1] - a[2] << endl;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
const int N = 501000;
int a[N];
int main()
{
    int T;
    cin >> T;
    for (;T--;)
    {
        int n;
        cin >> n;
        int num = 0;
        int lastx = -1;
        a[0] = 0;
        for (int i = 1;  i <= n; i++)
        {
           int x;
           cin >> x;
           if (x == lastx) a[num]++;
           else a[++num] = 1;
           lastx = x;
        }
        int p = 0;
        int sum = 0;
        int sum1 = 0;
        int i;
        for (i = 1; i <= num; i++)
        {
             if (sum + a[i] <= n/2)
             sum += a[i];
             else break;
        }
        int j = 1;
        if (num < 3) p = 1;
        else
        if (i < 3) p = 1;
        else
        {
            for (j = 2; j < i; j++)
            {
                sum1 += a[j];
                if (sum1 > a[1]) break;
            }
        }
        if (sum1 < a[1] || sum-a[1]-sum1 < a[1]) p = 1;
        if (p == 1)
        {
            cout << "0 0 0"<<endl;
        }
        else
        {
             cout << a[1] << " " << sum1 <<" "<< sum - a[1] - sum1 << endl;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
const int N = 501000;
int a[N];
int main()
{
    int T;
    cin >> T;
    for (;T--;)
    {
        int n;
        cin >> n;
        int num = 0;
        int lastx = -1;
        a[0] = 0;
        for (int i = 1;  i <= n; i++)
        {
           int x;
           cin >> x;
           if (x == lastx) a[num]++;
           else a[++num] = 1;
           lastx = x;
        }
        int p = 0;
        int sum = 0;
        int sum1 = 0;
        int i;
        for (i = 1; i <= num; i++)
        {
             if (sum + a[i] <= n/2)
             sum += a[i];
             else break;
        }
        int j = 1;
        if (num < 3) p = 1;
        else
        if (i < 3) p = 1;
        else
        {
            for (j = 2; j < i; j++)
            {
                sum1 += a[j];
                if (sum1 > a[1]) break;
            }
        }
        if (sum1 <= a[1] || sum-a[1]-sum1 <= a[1]) p = 1;
        if (p == 1)
        {
            cout << "0 0 0"<<endl;
        }
        else
        {
             cout << a[1] << " " << sum1 <<" "<< sum - a[1] - sum1 << endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e5+1;
int main () {
    int t;
    scanf("%d", &t);
    while (t--){
        int n;
        scanf("%d", &n);
        vector <int> a(n);
        set <int> s;
        map <int, int> mp;
        for (int &x:a){
            scanf("%d",&x);
            s.insert(x);
            mp[x]++;
        }
        if (s.size() < 3) {
            printf("0 0 0\n");
            continue;
        }
        auto it = --s.end();
        int gold = mp[*it];it--;
        int silver = mp[*it];it--;
        int ok = 1;
        while (silver <= gold) {
            silver += mp[*it];
            if (it != s.begin())
                it--;
            else {
                ok = 0;
                break;
            }
        }
        int bronze = mp[*it];it--;
        int S = bronze + gold + silver;
        while (bronze <= gold && ok) {
            bronze += mp[*it];
            if (it != s.begin())
                it--;
            else {
                ok = 0;
                break;
            }
        }
        while (S + mp[*it] < n/2 && ok) {
            S += mp[*it];
            bronze += mp[*it];
                if (it != s.begin())
                it--;
            else break;
        }
        if (silver > gold && bronze > gold && S <= (n/2)) {
            printf("%d %d %d\n",gold, silver, bronze);
        }
        else printf("0 0 0\n");
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e5+1;
int main () {
    int t;
    scanf("%d", &t);
    while (t--){
        int n;
        scanf("%d", &n);
        vector <int> a(n);
        set <int> s;
        map <int, int> mp;
        for (int &x:a){
            scanf("%d",&x);
            s.insert(x);
            mp[x]++;
        }
        if (s.size() < 3) {
            printf("0 0 0\n");
            continue;
        }
        auto it = --s.end();
        int gold = mp[*it];it--;
        int silver = mp[*it];it--;
        while (silver <= gold) {
            silver += mp[*it];
            if (it != s.begin())
                it--;
            else break;
        }
        int bronze = mp[*it];it--;
        while (bronze <= gold) {
            bronze += mp[*it];
            if (it != s.begin())
                it--;
            else break;
        }
        if (silver > gold && bronze > gold && (silver + bronze + gold) <= (n/2)) {
            printf("%d %d %d\n",gold, silver, bronze);
        }
        else printf("0 0 0\n");
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e5+1;
int main () {
    int t;
    scanf("%d", &t);
    while (t--){
        int n;
        scanf("%d", &n);
        vector <int> a(n);
        set <int> s;
        map <int, int> mp;
        for (int &x:a){
            scanf("%d",&x);
            s.insert(x);
            mp[x]++;
        }
        if (s.size() < 3) {
            printf("0 0 0\n");
            continue;
        }
        auto it = --s.end();
        ll gold = mp[*it];it--;
        ll silver = mp[*it];it--;
        int ok = 1;
        while (silver <= gold) {
            silver += mp[*it];
            if (it != s.begin())
                it--;
            else {
                ok = 0;
                break;
            }
        }
        ll bronze = mp[*it];it--;
        ll S = bronze + gold + silver;
        while (bronze <= gold && ok) {
            bronze += mp[*it];
            if (it != s.begin())
                it--;
            else {
                ok = 0;
                break;
            }
        }
        while (S  < n/2 && ok) {
            if (S + mp[*it] > n/2) {
                S += n/2 - S;
            bronze +=n/2 - S;
            }
            else {
                S += mp[*it];
                bronze += mp[*it];
            }
                if (it != s.begin())
                it--;
            else break;
        }
        if (silver > gold && bronze > gold && S <= (n/2)) {
            printf("%I64d %I64d %I64d\n",gold, silver, bronze);
        }
        else printf("0 0 0\n");
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e5+1;
int main () {
    int t;
    scanf("%d", &t);
    while (t--){
        int n;
        scanf("%d", &n);
        vector <int> a(n);
        set <int> s;
        map <int, int> mp;
        for (int &x:a){
            scanf("%d",&x);
            s.insert(x);
            mp[x]++;
        }
        if (s.size() < 3) {
            printf("0 0 0\n");
            continue;
        }
        auto it = --s.end();
        ll gold = mp[*it];it--;
        ll silver = mp[*it];it--;
        int ok = 1;
        while (silver <= gold) {
            silver += mp[*it];
            if (it != s.begin())
                it--;
            else {
                ok = 0;
                break;
            }
        }
        ll bronze = mp[*it];it--;
        while (bronze <= gold && ok) {
            bronze += mp[*it];
            if (it != s.begin())
                it--;
            else {
                ok = 0;
                break;
            }
        }
        n/=2;
        ll S = bronze + gold + silver;
        while (S  < n && ok) {
            if (S + mp[*it] > n) {
                int r = S;
                S = n;
                bronze += S - r;
            }
            else {
                S += mp[*it];
                bronze += mp[*it];
            }
            if (it != s.begin())
                it--;
            else break;
        }
        if (silver > gold && bronze > gold && S <= n) {
            printf("%I64d %I64d %I64d\n",gold, silver, bronze);
        }
        else printf("0 0 0\n");
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e5+1;
int main () {
    int t;
    scanf("%d", &t);
    while (t--){
        int n;
        scanf("%d", &n);
        vector <int> a(n);
        set <int> s;
        map <int, int> mp;
        for (int &x:a){
            scanf("%d",&x);
            s.insert(x);
            mp[x]++;
        }
        if (s.size() < 3) {
            printf("0 0 0\n");
            continue;
        }
        auto it = --s.end();
        ll gold = mp[*it];it--;
        ll silver = mp[*it];it--;
        int ok = 1;
        while (silver <= gold) {
            silver += mp[*it];
            if (it != s.begin())
                it--;
            else {
                ok = 0;
                break;
            }
        }
        ll bronze = mp[*it];it--;
        int S = bronze + gold + silver;
        while (bronze <= gold && ok) {
            bronze += mp[*it];
            if (it != s.begin())
                it--;
            else {
                ok = 0;
                break;
            }
        }
        while (S + mp[*it] < n/2 && ok) {
            S += mp[*it];
            bronze += mp[*it];
                if (it != s.begin())
                it--;
            else break;
        }
        if (silver > gold && bronze > gold && S <= (n/2)) {
            printf("%I64d %I64d %I64d\n",gold, silver, bronze);
        }
        else printf("0 0 0\n");
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e5+1;
int main () {
    int t;
    scanf("%d", &t);
    while (t--){
        int n;
        scanf("%d", &n);
        vector <int> a(n);
        set <int> s;
        map <int, int> mp;
        for (int &x:a){
            scanf("%d",&x);
            s.insert(x);
            mp[x]++;
        }
        if (s.size() < 3) {
            printf("0 0 0\n");
            continue;
        }
        auto it = --s.end();
        ll gold = mp[*it];it--;
        ll silver = mp[*it];it--;
        int ok = 1;
        while (silver <= gold) {
            silver += mp[*it];
            if (it != s.begin())
                it--;
            else {
                ok = 0;
                break;
            }
        }
        ll bronze = mp[*it];it--;
        while (bronze <= gold && ok) {
            bronze += mp[*it];
            if (it != s.begin())
                it--;
            else {
                ok = 0;
                break;
            }
        }
        n/=2;
        ll S = bronze + gold + silver;
        while (S  < n && ok) {
            if (S + mp[*it] > n) {
                break;
                //int r = S;
                //S = n;
                //bronze += S - r;
            }
            else {
                S += mp[*it];
                bronze += mp[*it];
            }
            if (it != s.begin())
                it--;
            else break;
        }
        if (silver > gold && bronze > gold && S <= n) {
            printf("%I64d %I64d %I64d\n",gold, silver, bronze);
        }
        else printf("0 0 0\n");
    }
}


#include<bits/stdc++.h>
using namespace std;
int ar[400005],lr;
int pt(int l,int r){
	int len=r-l+1;
	if(len%2){
		int mid=(l+r)>>1,i=1,m=len>>1;
		while(i<=m&&ar[mid-i]==ar[mid-i+1]&&ar[mid+i]==ar[mid+i-1])
			i++;
		if(ar[mid-i]!=ar[mid-i+1])
			lr=-1;
		if(ar[mid+i]!=ar[mid+i-1])
			lr=1;
		return m-i+1;
	}
	else{
		int mid=(l+r)>>1,i=1,m=len>>1;
		if(ar[mid]!=ar[mid+1])
			return m;
		while(i<m&&ar[mid-i]==ar[mid-i+1]&&ar[mid+i+1]==ar[mid+i])
			i++;
		if(ar[mid-i]!=ar[mid-i+1])
			lr=-1;
		if(ar[mid+i+1]!=ar[mid+i])
			lr=1;
		return m-i;
	}
}
int main(){
	int T,n,i,a,b,c,mxn,d;
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		a=b=c=0;
		for(i=n;i;i--)
			scanf("%d",&ar[i]);
		mxn=n/2;
		while(mxn&&ar[n-mxn]==ar[n-mxn+1])
			mxn--;
		if(mxn<5){
			puts("0 0 0");
			continue;
		}
		a=(mxn+1)/3-1;
		i=n-a;
		while(i<n&&ar[i]==ar[i+1])
			i++;
		a=n-i;
		while((d=pt(n-mxn+1,n-a))<=a&&a){
			i=n-a+1;
			while(i<n&&ar[i]==ar[i+1])
				i++;
			a=n-i;
		}
		if(lr==1){
			b=d;
			c=mxn-a-b;
		}
		else{
			c=d;
			b=mxn-a-c;
		}
		if(!a||!b||!c)
			puts("0 0 0");
		else
			printf("%d %d %d\n",a,b,c);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int ar[400005];
int pt(int l,int r){
	int len=r-l+1;
	if(len%2){
		int mid=(l+r)>>1,i=1,m=len>>1;
		while(i<=m&&ar[mid-i]==ar[mid-i+1]&&ar[mid+i]==ar[mid+i-1])
			i++;
		return m-i+1;
	}
	else{
		int mid=(l+r)>>1,i=1,m=len>>1;
		if(ar[mid]!=ar[mid+1])
			return m;
		while(i<m&&ar[mid-i]==ar[mid-i+1]&&ar[mid+i+1]==ar[mid+i])
			i++;
		return m-i;
	}
}
int main(){
	int T,n,i,a,b,c,mxn,d;
	cin>>T;
	while(T--){
		cin>>n;
		a=b=c=0;
		for(i=n;i;i--)
			cin>>ar[i];
		mxn=n/2;
		while(mxn&&ar[n-mxn]==ar[n-mxn+1])
			mxn--;
		if(mxn<3){
			cout<<"0 0 0\n";
			continue;
		}
		a=(mxn+1)/3-1;
		while((d=pt(n-mxn+1,n-a))<=a&&a){
			i=n-a+1;
			while(i<n&&ar[i]==ar[i+1])
				i++;
			a=n-i;
		}
		b=d;
		c=mxn-a-b;
		if(!a||!b||!c)
			cout<<"0 0 0\n";
		else
			cout<<a<<' '<<b<<' '<<c<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int ar[400005],lr;
int pt(int l,int r){
	int len=r-l+1;
	if(len%2){
		int mid=(l+r)>>1,i=1,m=len>>1;
		while(i<=m&&ar[mid-i]==ar[mid-i+1]&&ar[mid+i]==ar[mid+i-1])
			i++;
		if(ar[mid-i]!=ar[mid-i+1])
			lr=-1;
		if(ar[mid+i]!=ar[mid+i-1])
			lr=1;
		return m-i+1;
	}
	else{
		int mid=(l+r)>>1,i=1,m=len>>1;
		if(ar[mid]!=ar[mid+1])
			return m;
		while(i<m&&ar[mid-i]==ar[mid-i+1]&&ar[mid+i+1]==ar[mid+i])
			i++;
		if(ar[mid-i]!=ar[mid-i+1])
			lr=-1;
		if(ar[mid+i+1]!=ar[mid+i])
			lr=1;
		return m-i;
	}
}
int main(){
	int T,n,i,a,b,c,mxn,d;
	cin>>T;
	while(T--){
		cin>>n;
		a=b=c=0;
		for(i=n;i;i--)
			cin>>ar[i];
		mxn=n/2;
		while(mxn&&ar[n-mxn]==ar[n-mxn+1])
			mxn--;
		if(mxn<3){
			cout<<"0 0 0\n";
			continue;
		}
		a=(mxn+1)/3-1;
		while((d=pt(n-mxn+1,n-a))<=a&&a){
			i=n-a+1;
			while(i<n&&ar[i]==ar[i+1])
				i++;
			a=n-i;
		}
		if(lr==1){
			b=d;
			c=mxn-a-b;
		}
		else{
			c=d;
			b=mxn-a-c;
		}
		if(!a||!b||!c)
			cout<<"0 0 0\n";
		else
			cout<<a<<' '<<b<<' '<<c<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int ar[400005];
int pt(int l,int r){
	int len=r-l+1;
	if(len%2){
		int mid=(l+r)>>1,i=1,m=len>>1;
		while(i<=m&&ar[mid-i]==ar[mid-i+1]&&ar[mid+i]==ar[mid+i-1])
			i++;
		return m-i+1;
	}
	else{
		int mid=(l+r)>>1,i=1,m=len>>1;
		if(ar[mid]!=ar[mid+1])
			return m;
		while(i<m&&ar[mid-i]==ar[mid-i+1]&&ar[mid+i+1]==ar[mid+i])
			i++;
		return m-i;
	}
}
int main(){
	int T,n,i,a,b,c,p,mxn,d;
	cin>>T;
	while(T--){
		cin>>n;
		a=b=c=0;
		mxn=n/2;
		for(i=n;i;i--)
			cin>>ar[i];
		p=lower_bound(ar+n+1-mxn,ar+n+1,ar[n/2]+1)-ar;
		if(p==n+1){
			cout<<"0 0 0\n";
			continue;
		}
		while(mxn&&ar[n-mxn]==ar[n-mxn+1])
			mxn--;
		a=(mxn+1)/3-1;
		while(a&&(d=pt(n-mxn+1,n-a))<=a){
			i=n-a+1;
			while(i<n&&ar[i]==ar[i+1])
				i++;
			a=n-i;
		}
		b=d;
		c=mxn-a-b;
		if(!a||!b||!c)
			cout<<"0 0 0\n";
		else
			cout<<a<<' '<<b<<' '<<c<<endl;
	}

	return 0;
}


#include <iostream>

#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN = 4*1e5+5;
int a[MAXN];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		vector<int>ss[4];
		int n;
		cin>>n;
        if(n<8) {cout<<0<<' '<<0<<' '<<0<<endl;continue;}
		for(int y = 1;y<=n;y++)
		{
			cin>>a[y];
		}
		int dx = n/2;
		while(a[dx]==a[dx+1]&&dx>0)
		{
			dx--;
		}
		if(dx<=1)
		{
		cout<<0<<' '<<0<<' '<<0<<endl;continue;
		}
		int MAX = a[1];
        int j;
		for(j = 1;j<=dx;j++)
		{
			if(MAX == a[j]) ss[1].push_back(a[j]);
            else break;
		}
		for(;j<=dx;j++)
		{
			if(ss[2].size()<=ss[1].size())
			{
				ss[2].push_back(a[j]);
			}
			if(ss[2].size()>ss[1].size())
			{
			    if(ss[2].back()!=a[j])
			    {
			    	ss[3].push_back(a[j]);
				}
				else ss[2].push_back(a[j]);
			}
		}
		if(ss[1].size()<ss[2].size()&&ss[1].size()<ss[3].size())
		{
			cout<<ss[1].size()<<' '<<ss[2].size()<<' '<<ss[3].size()<<endl;
		}
		else cout<<0<<' '<<0<<' '<<0<<endl;
	}
	return 0;
}


#include <iostream>

#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN = 4*1e5+5;
int a[MAXN];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		vector<int>ss[4];
        ss[1].clear();
        ss[2].clear();
        ss[3].clear();
		int n;
		cin>>n;
		for(int y = 1;y<=n;y++)
		{
			cin>>a[y];
		}
		int dx = n/2;
        int q = a[dx];
        if(q==a[dx+1])
        {
            for(dx;dx>=1;dx--)
            {
                if(a[dx]!=q) break;
            }
        }
		int MAX = a[1];
        int j;
		for(j = 1;j<=dx;j++)
		{
			if(MAX == a[j]) ss[1].push_back(a[j]);
            else break;
		}
        j++;
		for(;j<=dx;j++)
		{
			if(ss[2].size()<=ss[1].size())
			{
				ss[2].push_back(a[j]);
			}
			if(ss[2].size()>ss[1].size())
			{
			    if(ss[2].back()!=a[j])
			    {
			    	ss[3].push_back(a[j]);
				}
				else ss[2].push_back(a[j]);
			}
		}
		if(ss[1].size()<ss[2].size()&&ss[1].size()<ss[3].size())
		{
			cout<<ss[1].size()<<' '<<ss[2].size()<<' '<<ss[3].size()<<endl;
		}
		else cout<<0<<' '<<0<<' '<<0<<endl;
	}
	return 0;
}


#include <iostream>

#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN = 4*1e5+5;
int a[MAXN];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		vector<int>ss[4];
        ss[1].clear();
        ss[2].clear();
        ss[3].clear();
		int n;
		cin>>n;
		for(int y = 1;y<=n;y++)
		{
			cin>>a[y];
		}
		int dx = n/2;
		while(a[dx]==a[dx+1])
		{
			dx--;
		}
		int MAX = a[1];
        int j;
		for(j = 1;j<=dx;j++)
		{
			if(MAX == a[j]) ss[1].push_back(a[j]);
            else break;
		}
        j++;
		for(;j<=dx;j++)
		{
			if(ss[2].size()<=ss[1].size())
			{
				ss[2].push_back(a[j]);
			}
			if(ss[2].size()>ss[1].size())
			{
			    if(ss[2].back()!=a[j])
			    {
			    	ss[3].push_back(a[j]);
				}
				else ss[2].push_back(a[j]);
			}
		}
		if(ss[1].size()<ss[2].size()&&ss[1].size()<ss[3].size())
		{
			cout<<ss[1].size()<<' '<<ss[2].size()<<' '<<ss[3].size()<<endl;
		}
		else cout<<0<<' '<<0<<' '<<0<<endl;
	}
	return 0;
}


#include <iostream>

#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN = 4*1e5+5;
int a[MAXN];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		vector<int>ss[4];
        ss[1].clear();
        ss[2].clear();
        ss[3].clear();
		int n;
		cin>>n;
		for(int y = 1;y<=n;y++)
		{
			cin>>a[y];
		}
		int dx = n/2;
		while(a[dx]==a[dx+1]&&dx>0)
		{
			dx--;
		}
        if(dx<=1) {
            cout<<0<<' '<<0<<' '<<0<<endl;continue;
        }
		int MAX = a[1];
        int j;
		for(j = 1;j<=dx;j++)
		{
			if(MAX == a[j]) ss[1].push_back(a[j]);
            else break;
		}
        j++;
		for(;j<=dx;j++)
		{
			if(ss[2].size()<=ss[1].size())
			{
				ss[2].push_back(a[j]);
			}
			if(ss[2].size()>ss[1].size())
			{
			    if(ss[2].back()!=a[j])
			    {
			    	ss[3].push_back(a[j]);
				}
				else ss[2].push_back(a[j]);
			}
		}
		if(ss[1].size()<ss[2].size()&&ss[1].size()<ss[3].size())
		{
			cout<<ss[1].size()<<' '<<ss[2].size()<<' '<<ss[3].size()<<endl;
		}
		else cout<<0<<' '<<0<<' '<<0<<endl;
	}
	return 0;
}


#include <iostream>

#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN = 4*1e5+5;
int a[MAXN];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		vector<int>ss[4];
        ss[1].clear();
        ss[2].clear();
        ss[3].clear();
		int n;
		cin>>n;
		for(int y = 1;y<=n;y++)
		{
			cin>>a[y];
		}
		int dx = n/2;
        int q = a[dx];
        if(q==a[dx+1])
        {
            for(dx;dx>=1;dx--)
            {
                if(a[dx]!=q) break;
            }
        }
		int MAX = a[1];
        int j;
		for(j = 1;j<=dx;j++)
		{
			if(MAX == a[j]) ss[1].push_back(a[j]);
            else break;
		}
		for(;j<=dx;j++)
		{
			if(ss[2].size()<=ss[1].size())
			{
				ss[2].push_back(a[j]);
			}
		else
			{

			    if(ss[2].back()!=a[j])
			    {
			    	ss[3].push_back(a[j]);
				}
				else ss[2].push_back(a[j]);
			}
		}
		if(ss[1].size()<ss[2].size()&&ss[1].size()<ss[3].size())
		{
			cout<<ss[1].size()<<' '<<ss[2].size()<<' '<<ss[3].size()<<endl;
		}
		else cout<<0<<' '<<0<<' '<<0<<endl;
	}
	return 0;
}


# include <cstdio>
# include <cstring>
# include <algorithm>
# define ll long long
using namespace std;
const int NR = 400051;
int nm, t, n;
int p[NR];
int s[NR], b[NR];
int main(){
//	freopen("1.in", "r", stdin);
	scanf("%d", &t);
	while (t--){
		scanf("%d", &n);
		nm = -1;
		int ans = -1;
		memset(s, -1, sizeof(s));
		memset(b, -1, sizeof(b));
		for (int i = 1; i <= n; i++){
			scanf("%d", p + i);
			if (p[i] != p[1] && nm == -1) nm = i - 1;
		}
		if (nm * 3 + 2 > n / 2){
			printf("0 0 0\n");
			continue;
		}
		for (int i = nm + 1; i <= n / 2; i++){
			int j = i;
			while (p[j + 1] == p[j]) j++;
			if (j > n / 2) break;
			if (j <= 2 * nm){
				i = j;
				continue;
			}
			s[j + 1] = nm;
			if (s[i] != -1) b[j + 1] = i;
			if (b[j + 1] != -1) ans = j;
			i = j;
		}
		if (ans == -1) printf("0 0 0\n");
		else printf("%d %d %d\n", nm, b[ans + 1] - 1 - nm, ans - (b[ans + 1] - 1));
	}
	return 0;
}


# include <cstdio>
# include <cstring>
# include <algorithm>
# define ll long long
using namespace std;
const int NR = 400051;
int nm, t, n, nm2;
int p[NR];
int s[NR], b[NR];
int main(){
	scanf("%d", &t);
	while (t--){
		scanf("%d", &n);
		nm = -1;
		int ans = -1;
		memset(s, -1, sizeof(s));
		memset(b, -1, sizeof(b));
		for (int i = 1; i <= n; i++){
			scanf("%d", p + i);
			if (p[i] != p[1] && nm == -1) nm = i - 1;
		}
		if (nm * 3 + 2 > n / 2){
			printf("0 0 0\n");
			continue;
		}
		for (int i = nm + 1; i <= n / 2; i++){
			int j = i;
			while (p[j + 1] == p[i]) j++;
			if (j > n / 2) break;
			if (j <= 2 * nm){
				i = j;
				continue;
			}
			nm2 = j;
			break;
		}
		for (int i = nm2 + 1; i <= n / 2; i++){
			if (p[i + 1] != p[i] && i - nm2 >= nm){
				ans = i;
			}
		}
		if (ans == -1) printf("0 0 0\n");
		else printf("%d %d %d\n", nm, nm2 - nm, ans - nm2);
	}
	return 0;
}


# include <cstdio>
# include <cstring>
# include <algorithm>
# define ll long long
using namespace std;
const int NR = 400051;
int nm, t, n, nm2;
int p[NR];
int s[NR], b[NR];
int main(){
	scanf("%d", &t);
	while (t--){
		scanf("%d", &n);
		nm = -1;
		nm2 = -1;
		int ans = -1;
		memset(s, -1, sizeof(s));
		memset(b, -1, sizeof(b));
		for (int i = 1; i <= n; i++){
			scanf("%d", p + i);
			if (p[i] != p[1] && nm == -1) nm = i - 1;
		}
		if (nm * 3 + 2 > n / 2 || nm == -1){
			printf("0 0 0\n");
			continue;
		}
		for (int i = nm + 1; i <= n / 2; i++){
			int j = i;
			while (p[j + 1] == p[i]) j++;
			if (j > n / 2) break;
			if (j <= 2 * nm){
				i = j;
				continue;
			}
			nm2 = j;
			break;
		}
		if (nm2 + nm + 1 > n / 2 || nm2 == -1){
			printf("0 0 0\n");
			continue;
		}
		for (int i = nm2 + 1; i <= n / 2; i++){
			if (p[i + 1] != p[i] && i - nm2 >= nm){
				ans = i;
			}
		}
		if (ans == -1) printf("0 0 0\n");
		else printf("%d %d %d\n", nm, nm2 - nm, ans - nm2);
	}
	return 0;
}


# include <cstdio>
# include <cstring>
# include <algorithm>
# define ll long long
using namespace std;
const int NR = 400051;
int nm, t, n, nm2;
int p[NR];
int s[NR], b[NR];
int main(){
	scanf("%d", &t);
	while (t--){
		scanf("%d", &n);
		nm = -1;
		nm2 = -1;
		int ans = -1;
		memset(s, -1, sizeof(s));
		memset(b, -1, sizeof(b));
		for (int i = 1; i <= n; i++){
			scanf("%d", p + i);
			if (p[i] != p[1] && nm == -1) nm = i - 1;
		}
		if (nm * 3 + 2 > n / 2 || nm == -1){
			printf("0 0 0\n");
			continue;
		}
		for (int i = nm + 1; i <= n / 2; i++){
			int j = i;
			while (p[j + 1] == p[i]) j++;
			if (j > n / 2) break;
			if (j <= 2 * nm){
				i = j;
				continue;
			}
			nm2 = j;
			break;
		}
		if (nm2 + nm + 1 > n / 2 || nm2 == -1){
			printf("0 0 0\n");
			continue;
		}
		for (int i = nm2 + 1; i <= n / 2; i++){
			if (p[i + 1] != p[i] && i - nm2 > nm){
				ans = i;
			}
		}
		if (ans == -1) printf("0 0 0\n");
		else printf("%d %d %d\n", nm, nm2 - nm, ans - nm2);
	}
	return 0;
}


# include <cstdio>
# include <cstring>
# include <algorithm>
# define ll long long
using namespace std;
const int NR = 400051;
int nm, t, n, nm2;
int p[NR];
int s[NR], b[NR];
int main(){
//	freopen("1.in", "r", stdin);
	scanf("%d", &t);
	while (t--){
		scanf("%d", &n);
		nm = -1;
		int ans = -1;
		memset(s, -1, sizeof(s));
		memset(b, -1, sizeof(b));
		for (int i = 1; i <= n; i++){
			scanf("%d", p + i);
			if (p[i] != p[1] && nm == -1) nm = i - 1;
		}
		if (nm * 3 + 2 > n / 2){
			printf("0 0 0\n");
			continue;
		}
		for (int i = nm + 1; i <= n / 2; i++){
			int j = i;
			while (p[j + 1] == p[i]) j++;
			if (j > n / 2) break;
			if (j <= 2 * nm){
				i = j;
				continue;
			}
			nm2 = j;
			break;
		}
		for (int i = nm2 + 1; i <= n / 2; i++){
			if (p[i + 1] != p[i]){
				ans = i;
			}
		}
		if (ans == -1) printf("0 0 0\n");
		else printf("%d %d %d\n", nm, nm2 - nm, ans - nm2);
	}
	return 0;
}


#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define si set < int >
#define vi vector < int >
#define pii pair < int, int >
#define mii map < int, int >
#define p_q priority_queue
#define INF ((1 << 30) - 1)
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define ull unsigned long long
#define mst(a, b) memset(a,b,sizeof(a))
#define foR(i, k, j) for(int i = (k); i >= (j); i--)
#define For(i, k, j) for(int i = (k); i <= (j); i++)
#define Foe(i, u) for(int i = lst[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define Fin(s) freopen(s, "r", stdin)
#define Fout(s) freopen(s, "w", stdout)
#define file(s) Fin(s".in"), Fout(s".out")
const int P = 998244353; //
using namespace std;
template <typename T> inline void ckmax(T &a, T b) {(a < b) && (a = b);}
inline void ckmin(string &a, string b) {
	if(a.size() < b.size() || a > b) a = b;
}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int add(int a, int b) {return a + b >= P ? a + b - P : a + b;}
inline int sub(int a, int b) {return a - b >= 0 ? a - b : a - b + P;}
inline void mulmod(int &a, int b) {a = mul(a, b);}
inline void addmod(int &a, int b) {((a += b) >= P) && (a -= P);}
inline void submod(int &a, int b) {((a -= b) < P) && (a += P);}
inline int ksm(int a, int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline int inv(int a) {return ksm(a, P-2);}
namespace FastIO {
    const int SIZE=1<<16; char buf[SIZE], obuf[SIZE], str[64]; int bi=SIZE, bn=SIZE, opt;
    int read_str(char *s) {
        while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
        int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
    }
    template <typename T> bool read(T& x) {if(x)x=0;int bf=0,n=read_str(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
    template <typename T> void write(T x) {
        if(!x) obuf[opt++] = '0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
        if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}
    }
    void write_char(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}}
    void Fflush() { if (opt) fwrite(obuf, 1, opt, stdout); opt=0;}
};
inline int read() {int x; FI(x); return x;}
const int MAXN = 505;
int n, K; string S;
string f[MAXN], g[MAXN];
char D(char c) {return c == 'a' ? 'a' + K - 1 : c - 1;}
char U(char c) {return c == 'a' + K - 1 ? 'a' : c + 1;}
char M(char c) {return min(c, min(D(c), U(c)));}
signed main()
{
    #ifndef ONLINE_JUDGE
        file("pro");
    #endif
    IOS;
	int T; cin >> T; while(T--) {
		cin >> n >> K >> S;
		For(i, 0, n) f[i] = "";
		For(i, 0, n) g[i] = "";
	    For(i, 0, n - 1) {
	    	ckmin(f[i + 1], f[i] + M(S[i]));
	    	if(i >= 1) ckmin(f[i + 1], f[i].substr(0, i - 1) + S[i] + f[i].substr(i - 1, 1));
	    	g[i + 1] = f[i] + S[i];
	    	if(i >= 1) ckmin(f[i + 1], g[i].substr(0, i - 1) + M(S[i]) + g[i].substr(i - 1, 1));
	    	if(i >= 2) ckmin(f[i + 1], g[i].substr(0, i - 2) + S[i] + g[i].substr(i - 2, 2));
	    	ckmin(f[i + 1], g[i] + S[i]);
	    }
	    cout << f[n] << endl;
	}
    return FastIO::Fflush(), 0;
}
/*

*/


#include <bits/stdc++.h>
using namespace std;

const int N = 505;

int n, k;
char s[N];

string dp[N];

string miniChar(char c) {
  char ret = (c + 1 == 'a' + k ? 'a' : (c == 'a' ? 'a' : c - 1));
  string r; r += ret;
  return r;
}

int solve() {
  scanf("%d %d", &n, &k);
  scanf("%s", s + 1);
  dp[0] = "";
  for (int i = 1; i <= n; ++i) {
    dp[i] = dp[i - 1] + miniChar(s[i]);
    if (i > 1) {
      string t = dp[i - 1] + s[i];
      swap(t[i - 2], t[i - 1]);
      dp[i] = min(dp[i], t);

      t = dp[i - 2] + miniChar(s[i]) + s[i - 1];
      dp[i] = min(dp[i], t);
    }
    if (i > 2) {
      string t = (dp[i - 2] + s[i]) + s[i - 1];
      swap(t[i - 3], t[i - 2]);
      dp[i] = min(dp[i], t);
    }
  }
  cout << dp[n] << endl;
  return 0;
}

int main() {
  int t = 1;
  scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;const int N = 505;int n, k;char s[N];string dp[N];
string miniChar(char c) {char ret = (c + 1 == 'a' + k ? 'a' : (c == 'a' ? 'a' : c - 1));string r; r += ret;return r;}
int solve() {scanf("%d %d", &n, &k);scanf("%s", s + 1);dp[0] = "";for (int i = 1; i <= n; ++i) {dp[i] = dp[i - 1] + miniChar(s[i]);
    if (i > 1) {string t = dp[i - 1] + s[i];swap(t[i - 2], t[i - 1]);dp[i] = min(dp[i], t);t = dp[i - 2] + miniChar(s[i]) + s[i - 1];dp[i] = min(dp[i], t);}
    if (i > 2) {string t = (dp[i - 2] + s[i]) + s[i - 1];swap(t[i - 3], t[i - 2]);dp[i] = min(dp[i], t);}}cout << dp[n] << endl;return 0;}
int main() {int t = 1;scanf("%d", &t);for (int tc = 0; tc < t; ++tc)solve();return 0;}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 505;

int n, k;
char cz;
bool vis[sz][27][27];
string s, dp[sz][27][27];

char cnv(char x) {
   if(x == 'a' || x == cz) return 'a';
   return x - 1;
}

string fnc(int i, char pch, char cch) {
   if(i >= n) return string(1, pch);
   int p = pch - 'a' + 1, c = cch - 'a' + 1;
   if(vis[i][p][c]) return dp[i][p][c];
   vis[i][p][c] = 1;

   string &now = dp[i][p][c];
   now.assign(n-i+1, cz);
   char nch = s[i+1];

   if(i < n-1) {
      if(pch < cch && pch < nch) {
         if(cnv(cch) <= cnv(nch)) now = pch + fnc(i+1, cnv(cch), nch);   // 1
         else now = pch + (cnv(nch) + fnc(i+2, cch, s[i+2]));   // 3
      }
      else if(cch < pch && cch < nch) now = cch + fnc(i+1, pch, nch);   // 2
      else if(nch < cch && nch < pch) now = nch + (pch + fnc(i+2, cch, s[i+2]));  // 4
      else if(pch == cch && cch == nch) now = pch + fnc(i+1, cnv(cch), nch);   // 1
      else {
         if(pch <= cch) now = pch + fnc(i+1, cnv(cch), nch);   // 1
         else now = cch + fnc(i+1, pch, nch);   // 2
         if(pch <= nch) now = min(now, pch + (cnv(nch) + fnc(i+2, cch, s[i+2])));   // 3
         else now = min(now, nch + (pch + fnc(i+2, cch, s[i+2])));  // 4
      }
   }
   else {
      if(pch <= cch) now = pch + fnc(i+1, cnv(cch), nch);
      else now = cch + fnc(i+1, pch, nch);
   }

   return now;
}

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0);
   int t;
   cin >> t;
   while(t--) {
      cin >> n >> k >> s;
      s += 'z'; cz = 'a' + k - 1;
      memset(vis, 0, sizeof(vis));
      cout << fnc(0, 'a', s[0]).substr(1, n) << '\n';
   }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 505;

int n, k;
char cz;
bool vis[sz][27][27];
string s, dp[sz][27][27];

char cnv(char x) {
   if(x == 'a' || x == cz) return 'a';
   return x - 1;
}

string fnc(int i, char pch, char cch) {
   if(i >= n) return string(1, pch);
   int p = pch - 'a' + 1, c = cch - 'a' + 1;
   if(vis[i][p][c]) return dp[i][p][c];
   vis[i][p][c] = 1;

   string &now = dp[i][p][c];
   now.assign(n - i + 1, cz);

   now = min(now, pch + fnc(i+1, cnv(cch), s[i+1]));

   now = min(now, cch + fnc(i+1, pch, s[i+1]));

   if(i < n-1) now = min(now, pch + (cnv(s[i+1]) + fnc(i+2, cch, s[i+2])));

   if(i < n-1) now = min(now, s[i+1] + (pch + fnc(i+2, cch, s[i+2])));

   return now;
}

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0);
   int t;
   cin >> t;
   while(t--) {
      cin >> n >> k >> s;
      s += 'z'; cz = 'a' + k - 1;
      memset(vis, 0, sizeof(vis));
      cout << fnc(0, 'a', s[0]).substr(1, n) << endl;
   }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 505;

int n, k;
char cz;
bool vis[sz][27][27];
string s, dp[sz][27][27];

char cnv(char x) {
   if(x == 'a' || x == cz) return 'a';
   return x - 1;
}

string fnc(int i, char pch, char cch) {
   if(i >= n) return string(1, pch);
   int p = pch - 'a' + 1, c = cch - 'a' + 1;
   if(vis[i][p][c]) return dp[i][p][c];
   vis[i][p][c] = 1;

   string &now = dp[i][p][c];
   now.assign(n-i+1, cz);
   char nch = s[i+1];

   if(i < n-1) {
      if(pch < cch && pch < nch) {
         if(cnv(cch) < cnv(nch)) now = pch + fnc(i+1, cnv(cch), nch);   // 1
         else if(cnv(cch) < cnv(nch)) now = pch + (cnv(nch) + fnc(i+2, cch, s[i+2]));   // 3
         else {
            now = pch + fnc(i+1, cnv(cch), nch);   // 1
            now = min(now, pch + (cnv(nch) + fnc(i+2, cch, s[i+2])));   // 3
         }
      }
      else if(cch < pch && cch < nch) now = cch + fnc(i+1, pch, nch);   // 2
      else if(nch < cch && nch < pch) now = nch + (pch + fnc(i+2, cch, s[i+2]));  // 4
      else if(pch == cch && cch == nch) now = pch + fnc(i+1, cnv(cch), nch);   // 1
      else {
         if(pch <= cch) now = pch + fnc(i+1, cnv(cch), nch);   // 1
         else now = cch + fnc(i+1, pch, nch);   // 2
         if(pch <= nch) now = min(now, pch + (cnv(nch) + fnc(i+2, cch, s[i+2])));   // 3
         else now = min(now, nch + (pch + fnc(i+2, cch, s[i+2])));  // 4
      }
   }
   else {
      if(pch <= cch) now = pch + fnc(i+1, cnv(cch), nch);
      else now = cch + fnc(i+1, pch, nch);
   }

   return now;
}

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0);
   int t;
   cin >> t;
   while(t--) {
      cin >> n >> k >> s;
      s += 'z'; cz = 'a' + k - 1;
      memset(vis, 0, sizeof(vis));
      cout << fnc(0, 'a', s[0]).substr(1, n) << '\n';
   }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 505;

int n, k;
char cz;
bool vis[sz][27][27];
string s, dp[sz][27][27];

char cnv(char x) {
   if(x == 'a' || x == cz) return 'a';
   return x - 1;
}

string fnc(int i, char pch, char cch) {
   if(i >= n) return string(1, pch);
   int p = pch - 'a' + 1, c = cch - 'a' + 1;
   if(vis[i][p][c]) return dp[i][p][c];
   vis[i][p][c] = 1;

   string &now = dp[i][p][c];

   if(pch <= cch) now = pch + fnc(i+1, cnv(cch), s[i+1]);
   else now = cch + fnc(i+1, pch, s[i+1]);

   if(i < n-1) {
      if(pch <= s[i+1]) now = min(now, pch + (cnv(s[i+1]) + fnc(i+2, cch, s[i+2])));
      if(s[i+1] <= pch) now = min(now, s[i+1] + (pch + fnc(i+2, cch, s[i+2])));
   }

   return now;
}

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0);
   int t;
   cin >> t;
   while(t--) {
      cin >> n >> k >> s;
      s += 'z'; cz = 'a' + k - 1;
      memset(vis, 0, sizeof(vis));
      cout << fnc(0, 'a', s[0]).substr(1, n) << endl;
   }
}


#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define xs(x) (ch[fa[x]][1]==x)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int ui;
typedef unsigned long long ul;
typedef long long ll;
typedef int n_;
const int maxn = 505;
const int maxm = 1000005;
const int maxlog = 32;
const int inf = 2147483647;
const double eps = 1e-9;
const double E = 2.718281828459;
const double PI = 3.1415926576;
const long long INF = 9223372036854775807ll;
inline ll qpow(ll a,ll b,ll c){register ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
const int mod = 1e9+7;int inv6=qpow(6,mod-2,mod);
inline void dec(n_ &x,n_ y){x-=y,x<0&&(x+=mod);}
inline void add(n_ &x,n_ y){x+=y,x>=mod&&(x-=mod);}
//inline n_ sum(n_ x,n_ y){return x+y<mod?x+y:x+y-mod;}
inline n_ sub(n_ x,n_ y){return x-y<0?x-y+mod:x-y;}
inline n_ sqr(n_ x){return 1ll*x*x%mod;}
inline n_ sm1(n_ x){return (1ll*x*(x+1)>>1)%mod;}
inline n_ sm2(n_ x){return 1ll*x*(x+1)%mod*(2*x+1)%mod*inv6%mod;}
inline n_ sm3(n_ x){return 1ll*sqr(x)*sqr(x+1)%mod;}
namespace IO{
	#define getchar() (tt == ss && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), ss == tt) ? EOF : *ss++)
	char In[1 << 20], *ss=In, *tt=In;//In����Ҫ�������������Ĵ�С
	const int END = 2147483647;//������
	//��������
	inline n_ rd(){//�޸�һ�±������ͼ���(int\ll\ul\ui)
		n_ x=0;int fg=1;
		char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		if(c=='-')fg=-1,c=getchar();
		while(isdigit(c)){
			x=(x<<3)+(x<<1)+(c-48);
			c=getchar();
		}
		return x*fg;
	}
	//�ַ�������
	inline int rds(char *s){
		register int len=0;
		register char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		while(c!=' ' && c!='\n' && c!='EOF'){
			s[len++]=c;
			c=getchar();
		}
		return len;
	}
	//����һ���ַ���
	inline int getline(char *s){
		register int len=0;
		register char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		while(c!='\n' && c!='EOF'){
			s[len++]=c;
			c=getchar();
		}
		return len;
	}
	//�������
	inline void wr(register n_ x){//���ӻ��з�
		if(x<0)putchar('-'),x=-x;
		if(x>=10)wr(x/10);
		putchar(x%10+'0');
	}
	inline void wrn(register n_ x){//�ӻ��з�
		wr(x);
		putchar('\n');
	}
	//��������ʽ�����
	inline void wrd(register n_ x,register int d){//���ӻ��з�
		if(!x){putchar('0');return;}
		register n_ xx =x;
		while(xx)d--,xx/=10;
		FOR(i,0,d)putchar('0');
		wr(x);
	}
	inline void wrdn(register n_ x,register int d){//�ӻ��з�
		wrd(x,d);
		putchar('\n');
	}
	//�ַ������
	inline void wrs(const char *s){//��������з�
		for(register int i=0;s[i];++i)putchar(s[i]);
	}
	inline void wrsn(const char *s){//������з�
		wrs(s);
		putchar('\n');
	}
	inline void debug(const char *s,n_ a=END,n_ b=END,n_ c=END,n_ d=END,n_ e=END,n_ f=END){
		if(s!=NULL)wrs(s),putchar(' ');
		if(a!=END)wr(a),putchar(' ');
		if(b!=END)wr(b),putchar(' ');
		if(c!=END)wr(c),putchar(' ');
		if(d!=END)wr(d),putchar(' ');
		if(e!=END)wr(e),putchar(' ');
		if(f!=END)wr(f),putchar(' ');
		putchar('\n');
	}
}
using namespace IO;

char s[maxn],ans[maxn];
int k,n;
char f(char c){
	if(c-'a'+1==k || c-'a'==0)return 'a';
	return c-1;
}

int main(){
	int t=rd();
	while(t--){
		n=rd(),k=rd();
		rds(s+1);
		s[n+1]='\0';
		int tot=0,fg=1;
		FOR(i,1,n){
			char a=fg?f(s[i]):s[i];
			char b=fg?f(s[i+1]):s[i+1];
			fg=0;
			if(i+2<=n && min(a,b)>s[i+2]){
				ans[tot++]=s[i+2];
				ans[tot++]=a;
				s[i+2]=s[i+1];
				i++;
			}else if(b<a){
				ans[tot++]=b;
				s[i+1]=b==s[i+1]?a:s[i];
			}else {
				ans[tot++]=a;
				fg=1;
			}
		}
		ans[tot++]=fg?f(s[n]):s[n];
		ans[tot]='\0';
		wrsn(ans);
	}
}


import java.util.Scanner;

public class CodeForce {
        public static void main(String[] args)
          {
              Scanner s = new Scanner(System.in);
              int t = s.nextInt();
              while(t>0)
              {
                 String n = s.next();
                 System.out.println(n.length());
              t--;
              }
          }
 }


import java.util.Scanner;

public class cp2 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();

		for(int i = 0;i<t;i++) {
			String n = in.next();
			int l = n.length();
			System.out.println(l);

		}

	}

}


import java.math.BigInteger;
import java.util.*;

import java.util.Scanner;

public class StrangeFunctions {

	public static int getCount(BigInteger number) {
		  double factor = Math.log(2) / Math.log(10);
		  int Count = (int) (factor * number.bitLength() + 1);
		  if (BigInteger.TEN.pow(Count - 1).compareTo(number) > 0) {
		    return Count - 1;
		  }
		  return Count;
		}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0) {
			BigInteger n = sc.nextBigInteger();
			System.out.println(getCount(n));
		}
	}

}


import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
String z=sc.nextLine();
String n=sc.nextLine();
System.out.println(n.length());
}
}
}


import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
String z=sc.nextLine();
while(t-->0){
String n=sc.nextLine();
System.out.println(n.length());
}
}
}


import java.util.*;
import java.math.BigInteger;
public class Main{

public static void method(BigInteger n){
HashSet<Integer>hash=new HashSet<Integer>();
BigInteger i;
BigInteger x;
BigInteger ten=new BigInteger("10");
BigInteger zero=new BigInteger("0");
for(i=BigInteger.valueOf(1);i.compareTo(n)<=0;i=i.add(BigInteger.ONE)){
x=i;
while(x.mod(ten).compareTo(zero)==0){
x=x.divide(ten);
}
BigInteger Gx=i.divide(x);
int Gxx=Gx.intValue();
hash.add(Gxx);
}
System.out.println(hash.size());
hash.clear();
}

public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
BigInteger n=sc.nextBigInteger();
method(n);
}
}
}


public class problems {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t>0) {
			String s=sc.next();
			solve(s);
			t--;
		}
	}
	static void solve(String n) {
		System.out.println(n.length());
	}


import java.util.*;
public class problems {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t>0) {
			String s=sc.next();
			solve(s);
			t--;
		}
	}
	static void solve(String n) {
		System.out.println(n.length());
	}
}


import java.util.*;
public class problems {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t>0) {
			String s=sc.next();
			solve(s);
			t--;
		}
	}
	static void solve(String n) {
		System.out.println(n.length());
	}


import java.io.*;
import java.math.*;
import java.util.*;
public class A {
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader s = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    private static int[] rai(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        return arr;
    }

    private static int[][] rai(int n, int m) {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextInt();
            }
        }
        return arr;
    }

    private static long[] ral(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextLong();
        }
        return arr;
    }

    private static long[][] ral(int n, int m) {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextLong();
            }
        }
        return arr;
    }

    private static int ri() {
        return s.nextInt();
    }

    private static long rl() {
        return s.nextLong();
    }

    private static String rs() {
        return s.next();
    }
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc=new FastReader();
		int t,i,j,sum=0,c=0;
		BigInteger n;
		t=sc.nextInt();
		while(t-->0)
		{
			String s;
			s=sc.next();
			System.out.println(s.length());
		}
	}
}


import java.io.*;
import java.math.*;
import java.util.*;
public class E {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int t,i,j,sum=0,c=0;
		BigInteger n;
		t=sc.nextInt();
		while(t-->0)
		{
			n=sc.nextBigInteger();
			while(!n.equals(BigInteger.valueOf(0)))
			{
				c++;
				n=n.divide(BigInteger.valueOf(10));
			}
			System.out.println(c);
			c=0;
		}
	}
}


import java.util.*;
// import java.lang.*;
import java.io.*;

//           THIS TEMPLATE MADE BY AKSH BANSAL.

public class Solution {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        // ________________________________

        int t = sc.nextInt();
        StringBuilder output = new StringBuilder();

        while (t-- > 0) {
            String s = sc.nextLine();
            output.append(solver(s)).append("\n");
        }

        System.out.println(output);
        // _______________________________

//        int n = sc.nextInt();
//        int[] arr = new int[n];
//
//        for(int i=0;i<n;i++){
//           arr[i] = sc.nextInt();
//        }
//        System.out.println(solver(arr,n));
        // ________________________________
    }

    public static int solver(String s) {
       return s.length();
    }
}


import java.util.Scanner;
import java.math.BigDecimal;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long t=sc.nextLong();
		while(t>0){
			String n=sc.next();
			long sum=0;
			long len=n.length();
			for(;len!=0;sum++) {
				len--;
			}
			t--;
			System.out.println(sum);
		}
	}
}


import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t>0){
			long n=sc.nextLong();
			long sum=0;
			for(;n>0;sum++) {
				n/=10;
			}
			t--;
			System.out.println(sum);
		}
	}
}


import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-->0){
			long n=sc.nextLong();
			long sum=0;
			for(;n>0;sum++) {
				n/=10;
			}
			System.out.println(sum);
		}
	}
}


import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-->0){
			int n=sc.nextInt();
			int sum=0;
			for(;n>0;sum++) {
				n/=10;
			}
			System.out.println(sum);
		}
	}
}


import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-->0){
			int n=sc.nextInt();
			int nums[]=new int[n];
			int sum=0;
			for(;n>0;sum++) {
				n/=10;
			}
			System.out.println(sum);
		}
	}
}


import java.util.Scanner;

public class Codeforces {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        sc.nextLine();

        while(t-- >0){
            String str = sc.nextLine();
            int len = str.length();
            System.out.println(len);
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class strange {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		Scanner sc=new Scanner(System.in);
		int t = Integer.parseInt(br.readLine());
//		int t=sc.nextInt();

		while(t-->0) {
			String line = br.readLine();
//			long n=sc.nextLong();
//			int count=0;
//
//			while(n>0) {
//				count++;
//				n/=10;
//			}
			System.out.println(line.length());
//			String s=Long.toString(n);
//			int i=0;
//			boolean flag=false;
//			while(s.charAt(i)=='0') {
//				flag=true;
//				i++;
//			}
//		    if(flag)
//		    {
//		    	System.out.println(1);
//		    	continue;
//		    }
////			StringBuilder str=new StringBuilder(s.substring(i,s.length()));
////			String sn=new String(str.reverse());
//		    long n2=Long.parseLong(s.substring(i,s.length()));
//		    System.out.pri

		}

	}

}


// Rezk
import java.util.Scanner;
public class Codeforces {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n,m;
        String str;
        n = input.nextInt();
         str = input.nextLine();
        for(int i=0;i<n;++i){
            str = input.nextLine();//            if(s.length())
            System.out.println(str.length());
        }

    }

}


/ Rezk
import java.util.Scanner;
public class Codeforces {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n,m;
        String str;
        n = input.nextInt();
         str = input.nextLine();
        for(int i=0;i<n;++i){
            str = input.nextLine();//            if(s.length())
            System.out.println(str.length());
        }

    }

}


import java.io.*;
import java.util.*;
public class abc
{

     public static void main(String arg[])throws IOException
     {
          BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
          int t=Integer.parseInt(br.readLine());
          StringBuilder sb=new StringBuilder();
          while(t-->0)
          {
         String s=br.readLine();
         sb.append(String.valueOf(s.length())+"\n");
     }
     System.out.println(sb);
}
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codeforces
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(buf.readLine());
        StringBuilder sb=new StringBuilder();
        for(int i=0;i<t;i++)
        {
            String s=buf.readLine();
            char ch[]=s.toCharArray();
            sb.append(ch.length+"\n");
        }
        System.out.println(sb);
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codeforces
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(buf.readLine());
        StringBuilder sb=new StringBuilder();
        for(int i=0;i<t;i++)
        {
            String st1[]=(buf.readLine()).split(" ");
            int x=Integer.parseInt(st1[0]);
            int y=Integer.parseInt(st1[1]);
            sb.append((x-1)+" "+y+"\n");
        }
        System.out.println(sb);
    }
}


import java.io.*;
import java.util.*;
public class Func
{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int t=sc.nextInt();
    while(t-->0)
    {
      String n=sc.next();
      int c=n.length();
      char ch=n.charAt(0);

      System.out.println(c);
    }
  }
}


import java.util.Scanner;

public class eferf {
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();

		for (int i=0;i<t;i++) {

			int n = s.nextInt();
			int a =0;
			while(n!=0) {
				n = n/10;
				a+=1;
			}

			System.out.println(a);
		}
		//s.close();
	}
}


import java.util.Scanner;

public class eferf {
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		long t = s.nextLong();

		for (int i=0;i<t;i++) {

			long n = s.nextLong();
			int a =0;
			while(n!=0) {
				n = n/10;
				a+=1;
			}

			System.out.println(a);
		}
		//s.close();
	}
}


import java.math.BigInteger;
//public class eferf {
//
//}
import java.util.Scanner;

public class eferf {
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		long t = s.nextLong();

		for (int i=0;i<t;i++) {

			BigInteger n = s.nextBigInteger();
			BigInteger A  = new BigInteger("10");
			BigInteger B  = new BigInteger("0");
			int a =0;
			while(n.compareTo(B)>0) {
				n = n.divide(A);
				a+=1;
			}

			System.out.println(a);
		}
		//s.close();
	}
}


import java.util.*;
public class hello
{
    public static void main(String args[])
    {
        Scanner sc= new Scanner(System.in);
        int t=sc.nextInt();
        sc.nextLine();
        while(t-->0)
        {
            String s=sc.nextLine();
            System.out.println(s.length());
        }
    }
}