#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <iostream>
#include <ctime>
#include <bitset>
#define gc getchar()
#define ll long long
#define il inline
#define fi first
#define se second
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repn(i, b, a) for (int i = b; i >= a; --i)
#define ite iterator

using namespace std;

const int N = 5e5 + 5, mod = 998244353;

template<class o> il void qr(o &x) {
    x = 0; char c = gc; int f = 1;
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = gc;}
    while (c >= '0' && c <= '9') {x = x * 10 + (c ^ 48); c = gc;}
    x *= f;
}

template<class o> void qw(o x) {
    if(x / 10) qw(x / 10); putchar(x % 10 + 48);
}

template<class o> void pr1(o x) {
    if (x < 0) putchar('-'), x = -x;
    qw(x); putchar(' ');
}

template<class o> void pr2(o x) {
    if (x < 0) putchar('-'), x = -x;
    qw(x); puts("");
}

il int ksm(int a, int b = mod - 2) {
    int ans = 1;
    for (; b; b >>= 1, a = 1ll * a * a % mod)
        if (b & 1) ans = 1ll * ans * a % mod;
    return ans;
}

il int add(int a, int b) {return a += b, a >= mod ? a - mod : a;}
il int sub(int a, int b) {return a -= b, a < 0 ? a + mod : a;}

/* code */

vector<int> p[N];
pii q[N]; int a[N], b[N], siz[N];
bool vis[N], v[N]; int ans[N];

bool cmp(pii a, pii b) {
    return a.fi > b.fi;
}

void solve() {
    int m, n, k, s; qr(m), qr(k), qr(n), qr(s);
    rep (i, 1, m) qr(a[i]), p[a[i]].pb(i); int cnt = 0;
    rep (i, 1, s) {
        int x; qr(x);
        if (vis[x]) ++siz[x];
        else vis[x] = 1, b[++cnt] = x, siz[x] = 1;
    } int tmp = 0, r, l = 0x3f3f3f3f;
    rep (i, 1, cnt) {
        int x = b[i];
        if (siz[x] > p[x].size()) {puts("-1"); return ;}
        int sz = p[x].size();
        rep (j, 0, sz - 1) q[++tmp] = mk(p[x][j], j);
        l = min(l, p[x][sz - siz[x]]);
    } sort(q + 1, q + tmp + 1, cmp);
    int mn = 0x3f3f3f3f, L = 0, R = 0;
    rep (i, 1, tmp) {
        r = q[i].fi; int j = q[i].se, x = a[q[i].fi];
        int sum = min(r - l + 1, k);
        int d = r - l + 1 - sum;
        d += (l - 1 + k) % k;
        if (mn > d) mn = d, L = l, R = r;
        if (j - siz[x] < 0) break;
        l = min(l, p[x][j - siz[x]]);
    }
    if (m - mn < n * k) {puts("-1"); return ;}
    rep (i, L, R) {
        int x = a[i];
        if (vis[x]) {
            if (siz[x]) v[i] = 1, --siz[x];
        }
    } int c = min(R - L + 1, k) - s; int len = 0;
    rep (i, L, R) {
        int x = a[i];
        if (!v[i]) {
            if (c) --c;
            else ans[++len] = i;
        }
    }
    int pos = 1;
    if (k == 1) pos = max(1, L - 1);
    if (L > 1) pos = L - (L - 1 + k) % k + 1;
    rep (i, pos, L - 1) ans[++len] = i;
    if (pos - 1 >= (n - 1) * k) {
        int cost = (pos - 1) - (n - 1) * k;
        rep (i, 1, cost) ans[++len] = i;
    }
    pr2(len); sort(ans + 1, ans + len + 1);
    rep (i, 1, len) pr1(ans[i]);
}

int main() {
    //int T; qr(T); while (T--) {
        solve();
    //}
    return 0;
}


#include <bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<functional>
#include<numeric>
using namespace std;
#define FOR(i,a,b) for(i= a ; i < b ; ++i)
#define rep(i,n) FOR(i,0,n)
#define INF INT_MAX
#define ALL(x) x.begin(),x.end()
#define LET(x,a) __typeof(a) x(a)
#define IFOR(i,a,b) for(LET(i,a);i!=(b);++i)
#define EACH(it,v) IFOR(it,v.begin(),v.end())
#define pb push_back
#define sz(x) int(x.size())
#define mp make_pair
#define fill(x,v) memset(x,v,sizeof(x))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define si(n) scanf("%d",&n)
#define si2(a,b) scanf("%d%d",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c);
#define pi(n) printf("%d ",n)
#define pd(n) printf("%lf ",n);
#define pdl(n) printf("%lf\n",n);
#define pin(n) printf("%d\n",n)
#define pln(n) printf("%lld\n",n)
#define pl(n) printf("%lld ",n)
#define sl(n) scanf("%lld",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define scan(v,n) vector<int> v;rep(i,n){ int j;si(j);v.pb(j);}
#define mod (int)(1e9 + 7)
#define ll long long int
#define F first
#define S second

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m,k,n,s;
    cin>>m>>k>>n>>s;

    vector<int> a(m);
    for(int i=0;i<m;i++)  cin>>a[i];

    vector<int> b(s);
    unordered_map<int,int> mapping;
    int cnt = 0;
    for(int i=0;i<s;i++){
        cin>>b[i];
        if(mapping.find(b[i])==mapping.end()){
            cnt++;
            mapping[b[i]]++;
        }
        else{
            mapping[b[i]]++;
        }
    }
    int l,r = -1;
    unordered_map<int,int> curr_wind;
    int curr_cnt = 0;
    bool sol_found = false;

    for(l=0;l<m;l++){
        r = max(l,r);

        while(cnt!=curr_cnt&&r<m){
            if(mapping.find(a[r])!=mapping.end()){
                curr_wind[a[r]]++;
                if(curr_wind[a[r]]==mapping[a[r]]){
                    curr_cnt++;
                }
            }
            r++;
        }

        if(cnt==curr_cnt){
            int l1 = l;
            int r1 = max(r,l+k);

            int x = (l1/k) + (m-r1)/k + 1;

            if(x>=n){
                sol_found = true;
                break;
            }
        }
        curr_wind[a[l]]--;
        if(mapping.find(a[l])!=mapping.end() && mapping[a[l]]>curr_wind[a[l]]){
            curr_cnt--;
        }
    }

    if(!sol_found){
        cout<<"-1";
    }
    else{
        int char_rem = m - n*k;
        //cout<<l<<" "<<r<<endl;
        cout<<char_rem<<endl;
        --r;
        r = max(r,l+k-1);
        vector<int> res;
        vector<int> extra;

        //cout<<l<<" "<<r<<endl;
        for(int i=l;i<=r;i++){
            if(mapping.find(a[i])!=mapping.end()&&mapping[a[i]]<curr_wind[a[i]]){
                curr_wind[a[i]]--;
                extra.pb(i);
            } else if(mapping.find(a[i])==mapping.end()){
                extra.pb(i);
            }
        }

        int removed_so_far = (r-l+1-k);

        for(int i=0;i<removed_so_far;i++){
            res.pb(extra[i]);
        }
        vector<int> extras;

        int tempf = l%k;
        //cout<<tempf<<endl;
        for(int i=0;i<tempf;i++){
            extras.pb(i);
        }

        int temp = (m-r-1)%k;
        //cout<<temp<<endl;
        for(int i=m-1;i>=0&&temp>0;i--){
            temp--;
            extras.pb(i);
            //cout<<i<<" ";
        }

        //cout<<endl;
        while(char_rem>removed_so_far&&extras.size()>0){
            res.pb(extras.back());
            extras.pop_back();
            removed_so_far++;
        }

        //cout<<res.size()<<endl;

        int idx = tempf;
        while(char_rem>removed_so_far&&idx<l){
            res.pb(idx);
            idx++;
            removed_so_far++;
        }

        int ldx = r+1;
        while(char_rem>removed_so_far){
            res.pb(ldx);
            //cout<<ldx<<endl;
            ldx++;
            removed_so_far++;
        }

        sort(res.begin(), res.end());
        for(int i=0;i<res.size();i++){
            cout<<res[i]+1<<" ";
        }
    }

    return 0;
}


//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int m,k,n,s;cin>>m>>k>>n>>s;
	int a[m+1];
	unordered_map<int,int> m1,m2;
	for(int i=1;i<=m;i++)cin>>a[i];
	int ss[s];
	for(int i=0;i<s;i++){
		cin>>ss[i];
		m1[ss[i]]++;
	}
	int si=m1.size();
	int rem=m-n*k;
	if(m<n*k)return cout<<"-1",0;
	int cnt=0;
	//cout<<rem<<endl;
	int kk=rem+k;
	for(int i=1;i<=kk;i++){
		if(m1[a[i]]>0){
			m2[a[i]]++;
			if(m1[a[i]]==m2[a[i]])cnt++;
		}
	}
	//cout<<cnt<<endl;
	vi v;
	if(cnt>=si){
		int rt=0;
		for(int i=1;i<=kk;i++){
			if(rt<rem&&m1[a[i]]==0){
				v.pb(a[i]);
				rt++;
			}
			else if(rt<rem&&m1[a[i]]<m2[a[i]]){
				v.pb(i);
				m2[a[i]]--;
				rt++;
			}
		}
	}
	if(cnt==si){
		cout<<v.size()<<endl;
		for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
		return 0;
	}
	for(int i=kk+1;i<=m;i++){
		if(m1[a[i-kk]]>0){
			if(m1[a[i-kk+1]]==m2[a[i-kk+1]])cnt--;
			m2[a[i-kk+1]]--;
		}
		if(m1[a[i]]>0){
			m2[a[i]]++;
			if(m2[a[i]]==m1[a[i]])cnt++;
		}
		if(cnt>=si){
		//cout<<i<<endl;
		int rt=0;
		for(int j=i-kk+1;j<=i;j++){
			if(rt<rem&&m1[a[j]]==0){
				v.pb(j);
				rt++;
			}
			else if(rt<rem&&m1[a[j]]<m2[a[j]]){
				v.pb(a[j]);
				m2[a[j]]--;
			}
		}
			break;
		}
	}
    if(cnt>=si){
    	cout<<v.size()<<endl;
    	for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
	}
	else cout<<"-1"<<endl;
}


//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int m,k,n,s;cin>>m>>k>>n>>s;
	int a[m+1];
	unordered_map<int,int> m1,m2;
	for(int i=1;i<=m;i++)cin>>a[i];
	int ss[s];
	for(int i=0;i<s;i++){
		cin>>ss[i];
		m1[ss[i]]++;
	}
	int si=m1.size();
	int rem=m-n*k;
	if(m<n*k)return cout<<"-1",0;
	int cnt=0;
	//cout<<rem<<endl;
	int kk=rem+k;
	for(int i=1;i<=kk;i++){
		if(m1[a[i]]>0){
			m2[a[i]]++;
			if(m1[a[i]]==m2[a[i]])cnt++;
		}
	}
	//cout<<cnt<<endl;
	vi v;
	if(cnt>=si){
		int rt=0;
		for(int i=1;i<=kk;i++){
			if(rt<rem&&m1[a[i]]==0){
				v.pb(i);
				rt++;
			}
			else if(rt<rem&&m1[a[i]]<m2[a[i]]){
				v.pb(i);
				m2[a[i]]--;
				rt++;
			}
		}
	}
	if(cnt==si){
		cout<<v.size()<<endl;
		for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
		return 0;
	}
	for(int i=kk+1;i<=m;i++){
		if(m1[a[i-kk]]>0){
			if(m1[a[i-kk+1]]==m2[a[i-kk+1]])cnt--;
			m2[a[i-kk+1]]--;
		}
		if(m1[a[i]]>0){
			m2[a[i]]++;
			if(m2[a[i]]==m1[a[i]])cnt++;
		}
		if(cnt>=si){
		//cout<<i<<endl;
		int rt=0;
		for(int j=i-kk+1;j<=i;j++){
			if(rt<rem&&m1[a[j]]==0){
				v.pb(j);
				rt++;
			}
			else if(rt<rem&&m1[a[j]]<m2[a[j]]){
				v.pb(j);
				m2[a[j]]--;
			}
		}
			break;
		}
	}
    if(cnt>=si){
    	cout<<v.size()<<endl;
    	for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
	}
	else cout<<"-1"<<endl;
}


//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int m,k,n,s;cin>>m>>k>>n>>s;
	int a[m+1];
	unordered_map<int,int> m1,m2;
	for(int i=1;i<=m;i++)cin>>a[i];
	int ss[s];
	for(int i=0;i<s;i++){
		cin>>ss[i];
		m1[ss[i]]++;
	}
	int si=m1.size();
	int rem=m-n*k;
	if(m<n*k)return cout<<"-1",0;
	int cnt=0;
	//cout<<rem<<endl;
	int kk=rem+k;
	for(int i=1;i<=kk;i++){
		if(m1[a[i]]>0){
			m2[a[i]]++;
			if(m1[a[i]]==m2[a[i]])cnt++;
		}
	}
	//cout<<cnt<<endl;
	vi v;
	if(cnt>=si){
		int rt=0;
		for(int i=1;i<=kk;i++){
			if(rt<rem&&m1[a[i]]==0){
				v.pb(i);
				rt++;
			}
			else if(rt<rem&&m1[a[i]]<m2[a[i]]){
				v.pb(i);
				m2[a[i]]--;
				rt++;
			}
		}
	}
	if(cnt==si){
		cout<<v.size()<<endl;
		for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
		return 0;
	}
	for(int i=kk+1;i<=m;i++){
		if(m1[a[i-kk]]>0){
			if(m1[a[i-kk+1]]==m2[a[i-kk+1]])cnt--;
			m2[a[i-kk+1]]--;
		}
		if(m1[a[i]]>0){
			m2[a[i]]++;
			if(m2[a[i]]==m1[a[i]])cnt++;
		}
		if(cnt>=si){
		//cout<<i<<endl;
		int rt=0;
		for(int j=i-kk+1;j<=i;j++){
			if(rt<rem&&m1[a[j]]==0){
				v.pb(j);
				rt++;
			}
			else if(rt<rem&&m1[a[j]]<m2[a[j]]){
				v.pb(j);
				m2[a[j]]--;
				rt++;
			}
		}
			break;
		}
	}
    if(cnt>=si){
    	cout<<v.size()<<endl;
    	for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
	}
	else cout<<"-1"<<endl;
}


//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int m,k,n,s;cin>>m>>k>>n>>s;
	int a[m+1];
	unordered_map<int,int> m1,m2;
	for(int i=1;i<=m;i++)cin>>a[i];
	int ss[s];
	for(int i=0;i<s;i++){
		cin>>ss[i];
		m1[ss[i]]++;
	}
	int si=m1.size();
	int rem=m-n*k;
	if(m<n*k)return cout<<"-1",0;
	int cnt=0;
	//cout<<rem<<endl;
	int kk=rem+k;
	for(int i=1;i<=kk;i++){
		if(m1[a[i]]>0){
			m2[a[i]]++;
			if(m1[a[i]]==m2[a[i]])cnt++;
		}
	}
	//cout<<cnt<<endl;
	vi v;
	if(cnt>=si){
		int rt=0;
		for(int i=1;i<=kk;i++){
			if(rt<rem&&m1[a[i]]==0){
				v.pb(i);
				rt++;
			}
			else if(rt<rem&&m1[a[i]]<m2[a[i]]){
				v.pb(i);
				m2[a[i]]--;
				rt++;
			}
		}
	}
	if(cnt>=si){
		cout<<v.size()<<endl;
		for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
		return 0;
	}
	for(int i=kk+1;i<=m;i++){
		if(m1[a[i-kk]]>0){
			if(m1[a[i-kk]]==m2[a[i-kk]])cnt--;
			m2[a[i-kk]]--;
		}
		if(m1[a[i]]>0){
			m2[a[i]]++;
			if(m2[a[i]]==m1[a[i]])cnt++;
		}
		//cout<<cnt<<" "<<"x"<<endl;
		if((i-kk)%k==0&&cnt>=si){
		//cout<<i<<endl;
		int rt=0;
		for(int j=i-kk+1;j<=i;j++){
			if(rt<rem&&m1[a[j]]==0){
				v.pb(j);
				rt++;
			}
			else if(rt<rem&&m1[a[j]]<m2[a[j]]){
				v.pb(j);
				m2[a[j]]--;
				rt++;
			}
		}
			break;
		}
	}
    if(cnt>=si){
    	cout<<v.size()<<endl;
    	for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
	}
	else cout<<"-1"<<endl;
}


//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int m,k,n,s;cin>>m>>k>>n>>s;
	int a[m+1];
	unordered_map<int,int> m1,m2;
	for(int i=1;i<=m;i++)cin>>a[i];
	int ss[s];
	for(int i=0;i<s;i++){
		cin>>ss[i];
		m1[ss[i]]++;
	}
	int si=m1.size();
	int rem=m-n*k;
	if(m<n*k)return cout<<"-1",0;
	int cnt=0;
	//cout<<rem<<endl;
	int kk=rem+k;
	for(int i=1;i<=kk;i++){
		if(m1[a[i]]>0){
			m2[a[i]]++;
			if(m1[a[i]]==m2[a[i]])cnt++;
		}
	}
	//cout<<cnt<<endl;
	vi v;
	if(cnt>=si){
		int rt=0;
		for(int i=1;i<=kk;i++){
			if(rt<rem&&m1[a[i]]==0){
				v.pb(i);
				rt++;
			}
			else if(rt<rem&&m1[a[i]]<m2[a[i]]){
				v.pb(i);
				m2[a[i]]--;
				rt++;
			}
		}
	}
	if(cnt==si){
		cout<<v.size()<<endl;
		for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
		return 0;
	}
	for(int i=kk+1;i<=m;i++){
		if(m1[a[i-kk]]>0){
			if(m1[a[i-kk]]==m2[a[i-kk]])cnt--;
			m2[a[i-kk]]--;
		}
		if(m1[a[i]]>0){
			m2[a[i]]++;
			if(m2[a[i]]==m1[a[i]])cnt++;
		}
		if(cnt>=si){
		//cout<<i<<endl;
		int rt=0;
		for(int j=i-kk+1;j<=i;j++){
			if(rt<rem&&m1[a[j]]==0){
				v.pb(j);
				rt++;
			}
			else if(rt<rem&&m1[a[j]]<m2[a[j]]){
				v.pb(j);
				m2[a[j]]--;
				rt++;
			}
		}
			break;
		}
	}
    if(cnt>=si){
    	cout<<v.size()<<endl;
    	for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
	}
	else cout<<"-1"<<endl;
}


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=5e5+9;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}

		if(count)break;

		if((l-1)/k+(m-r+1)/k>=n-1)
		{
			cout<<(l-1)%k+(r-l-k)<<endl;
			int oo=r-l-k;
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
//	if(count==0)cout<<9<<endl;
	cout<<-1<<endl;
	return 0;
 }


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=1e5+9;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}
		//cout<<r<<endl;
		if(count)break;
//		if((l-1)/k+(m-r+1)/k>=n-1)
        int p = r-l-k;
        if(p<0)p=0;
        int q = l-((l-1)/k)*k-1;
        int sum = p+q;
        if(m-sum>=n*k)
		{
			//cout<<(l-1)%k+(r-l-k)<<endl;
			cout<<sum<<endl;
			int oo=r-l-k;
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			//cout<<endl;
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
//	if(count==0)cout<<9<<endl;
	cout<<-1<<endl;
	return 0;
 }


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=1e5+9;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}
		//cout<<r<<endl;
		if(count)break;
//		if((l-1)/k+(m-r+1)/k>=n-1)
        int p = max(0,r-l-k);
        int q = l-((l-1)/k)*k-1;
        int sum = p+q;
        if(m-sum>=n*k)
		{
			//cout<<(l-1)%k+(r-l-k)<<endl;
			cout<<sum<<endl;
			int oo=r-l-k;
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			//cout<<endl;
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
//	if(count==0)cout<<9<<endl;
	cout<<-1<<endl;
	return 0;
 }


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=5e5+10;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}

		if(count)break;

		if((l-1)/k+(m-r+1)/k>=n-1)
		{
			cout<<(l-1)%k+(r-l-k<0?0:r-l-k)<<endl;
			int oo=r-l-k;
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
//	if(count==0)cout<<9<<endl;
	cout<<-1<<endl;
	return 0;
 }


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=1e5+9;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}
		//cout<<r<<endl;
		if(count)break;
		if((l-1)/k+(m-r+1)/k>=n-1)
		{
			cout<<(l-1)%k+(r-l-k)<<endl;
			int oo=r-l-k;
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			//cout<<endl;
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
	if(count==0)cout<<9<<endl;
	cout<<-1<<endl;
	return 0;
 }


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=5e5+10;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}

		if(count)break;

		int tt=r-l-k;
		if(tt<0)tt=-tt;
		else tt=0;

		if((l-1)/k+(m-r+1-tt)/k>=n-1)
		{
			cout<<(l-1)%k+(r-l-k<0?0:r-l-k)<<endl;
			int oo=(r-l-k<0?0:r-l-k);
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
//	if(count==0)cout<<9<<endl;
	cout<<-1<<endl;
	return 0;
 }


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=5e5+10;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}

		if(count)break;

		if((l-1)/k+(m-r+1)/k>=n-1)
		{
			cout<<(l-1)%k+(r-l-k<0?:0,r-l-k)<<endl;
			int oo=r-l-k;
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
//	if(count==0)cout<<9<<endl;
	cout<<-1<<endl;
	return 0;
 }


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=1e5+9;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}
		//cout<<r<<endl;
		if(count)break;
		if((l-1)/k+(m-r+1)/k>=n-1)
		{
			cout<<(l-1)%k+(r-l-k)<<endl;
			int oo=r-l-k;
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			//cout<<endl;
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
	if(count)cout<<count<<endl;
	cout<<-1<<endl;
	return 0;
 }


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=1e5+9;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}
		//cout<<r<<endl;
		if(count)break;
		if((l-1)/k+(m-r+1)/k>=n-1)
		{
			cout<<(l-1)%k+(r-l-k)<<endl;
			int oo=r-l-k;
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			//cout<<endl;
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
	cout<<-1<<endl;
	return 0;
 }


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=1e5+9;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}
		//cout<<r<<endl;
		if(count)break;
		if((l-1)/k+(m-r+1)/k>=n-1&&(r-l>=k))
		{
			cout<<(l-1)%k+(r-l-k)<<endl;
			int oo=r-l-k;
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			//cout<<endl;
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
	cout<<-1<<endl;
	return 0;
 }


#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll N=1e5+9;
ll m,k,n,s;
ll a[N],b[N],c[N];
ll count;
int main()
{
	scanf("%lld%lld%lld%lld",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=s;i++)
	{
		ll t;
		scanf("%lld",&t);
		if(b[t]==0)count++;
		b[t]++;
	}

	int r=1;
	for(int l=1;l<=m;l++)
	{
		while(r<=m&&count)
		{
			c[a[r]]++;
			if(c[a[r]]==b[a[r]])count--;
			r++;
		}
		//cout<<r<<endl;
		if(count)break;
		if((l-1)/k+(m-r+1)/k>=n-1)
		{
			cout<<(l-1)%k+(r-l-k)<<endl;
			int oo=r-l-k;
			for(int i=1;i<=(l-1)%k;i++)cout<<i<<" ";
			//cout<<endl;
			for(int i=l;i<r;i++)
			if(c[a[i]]>b[a[i]]&&oo)c[a[i]]--,oo--,cout<<i<<" ";
			return 0;
		}
		c[a[l]]--;
		if(c[a[l]]<b[a[l]])count++;
	}
	//cout<<-1<<endl;
	return 0;
 }


#include <bits/stdc++.h>

#define INF INT_MAX
#define EPS 1e-6
#define pb push_back
#define pause system("pause");
#define exit exit(0)

using namespace std;
using ll = long long;
using ull = unsigned long long;

int m, k, n, s;
int a[500000];
int cnt[500000];
int mc[500000];

void check(int l, int r) {
	int ls = 0;
	int _l = k * (l / k);

	if (r - _l > k) {
		ls = r - _l - k;
	}

	if (ls > m - n * k) {
		return;
	}

	fill(cnt, cnt + 500000, 0);

	cout << ls << endl;
	for (int i = _l; i < r; ++i) {
		if (ls == 0) {
			break;
		}

		if (cnt[a[i]] == mc[a[i]]) {
			cout << i + 1 << ' ', --ls;
		} else {
			++cnt[a[i]];
		}
	}

	cout << endl;
	exit;
}

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

	cin >> m >> k >> n >> s;
	for (int i = 0; i < m; ++i) {
		cin >> a[i];
	}

	set<int> u;
	for (int i = 0, x; i < s; ++i) {
		cin >> x;
		++mc[x];
		u.insert(x);
	}

	int l = 0, r = 0, q = 0, nd = (int)(u.size());
	while (l < m) {
		while (r < m && q < nd) {
			++cnt[a[r]];
			if (cnt[a[r]] == mc[a[r]]) {
				++q;
			}

			++r;
		}

		if (q == nd) {
			check(l, r);
		}

		--cnt[a[l]];
		if (cnt[a[l]] < mc[a[l]]) {
			--q;
		}

		++l;
	}

	cout << -1 << endl;
	//pause;
	return 0;
}


#include <bits/stdc++.h>

#define INF INT_MAX
#define EPS 1e-6
#define pb push_back
#define pause system("pause");
#define exit exit(0)

using namespace std;
using ll = long long;
using ull = unsigned long long;

int m, k, n, s;
int a[500000];
int cnt[500001];
int mc[500001];

void check(int l, int r) {
	int ls = 0;
	int _l = k * (l / k);

	if (r - _l > k) {
		ls = r - _l - k;
	}

	if (ls > m - n * k) {
		return;
	}

	fill(cnt, cnt + 500000, 0);

	cout << ls << endl;
	for (int i = _l; i < r; ++i) {
		if (ls == 0) {
			break;
		}

		if (cnt[a[i]] == mc[a[i]]) {
			cout << i + 1 << ' ', --ls;
		} else {
			++cnt[a[i]];
		}
	}

	cout << endl;
	exit;
}

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

	cin >> m >> k >> n >> s;
	for (int i = 0; i < m; ++i) {
		cin >> a[i];
	}

	set<int> u;
	for (int i = 0, x; i < s; ++i) {
		cin >> x;
		++mc[x];
		u.insert(x);
	}

	int l = 0, r = 0, q = 0, nd = (int)(u.size());
	while (l < m) {
		while (r < m && q < nd) {
			++cnt[a[r]];
			if (cnt[a[r]] == mc[a[r]]) {
				++q;
			}

			++r;
		}

		if (q == nd) {
			check(l, r);
		}

		--cnt[a[l]];
		if (cnt[a[l]] < mc[a[l]]) {
			--q;
		}

		++l;
	}

	cout << -1 << endl;
	//pause;
	return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		ll val=query(1,1,n,i,pos-1);
		if(pos!=-1 && val==lmax[i-1]){
			cout<<"YES"<<endl;
			cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
			return;
		}
		pos++;
		if(pos!=0 && pos<n && val==lmax[i-1]){
			cout<<"YES"<<endl;
			cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
			return;
		}

	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
				// while(pos<=n){
				// 	ll val=query(1,1,n,i,pos-1);
				// 	if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
				// 		cout<<"YES"<<endl;
				// 		cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				// 		return;
				// 	}
				// 	pos++;
				// }
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos==-1)
			continue;
		while(pos<=n){
			ll val=query(1,1,n,i,pos-1);
			if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
				cout<<"YES"<<endl;
				cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				return;
			}
			pos++;
		}

	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 2e9;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
				while(pos<=n){
					ll val=query(1,1,n,i,pos-1);
					if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
						cout<<"YES"<<endl;
						cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
						return;
					}
					if(rmax[pos]<lmax[i-1])
						break;
					pos++;
				}
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos==-1)
			continue;
		while(pos<=n){
			ll val=query(1,1,n,i,pos-1);
			if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
				cout<<"YES"<<endl;
				cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				return;
			}
			if(rmax[pos]<lmax[i-1])
				break;
			pos++;
		}

	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	// cout<<vec<<endl;
	// cout<<lmax<<endl;
	// cout<<rmax<<endl;
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos!=-1 && query(1,1,n,i,pos-1)==lmax[i-1]){
			cout<<"YES"<<endl;
			cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
			return;
		}
	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	// cout<<vec<<endl;
	// cout<<lmax<<endl;
	// cout<<rmax<<endl;
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
				if(pos!=-1 && query(1,1,n,i,pos-1)==lmax[i-1]){
					cout<<"YES"<<endl;
					cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
					return;
				}
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	// cout<<vec<<endl;
	// cout<<lmax<<endl;
	// cout<<rmax<<endl;
	for(int i=2;i<n;++i){
		int low=i,high=n-1,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			int val=query(1,1,n,i,mid);
			// cout<<i<<" "<<mid<<" "<<val<<endl;
			if(val==lmax[i-1]){
				pos=mid;
				low=mid+1;
				// cout<<i<<" "<<pos<<endl;
				if(pos!=-1 && lmax[i-1]==rmax[pos+1]){
					cout<<"YES"<<endl;
					cout<<i-1<<" "<<pos-i+1<<" "<<n-pos<<endl;
					return;
				}
			}
			else if(val<lmax[i-1]){
				high=mid-1;
			}
			else{
				high=mid-1;
			}
		}
	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define db long double
#define rep(i,p,q) for(i=p;i<q;++i)
#define REP(i,p,q) for(i=p;i<=q;++i)
#define MOD 1000000007
#define stop return 0
#define pb push_back
#define nil 1000000010
#define initial 0
#define waiting 1
#define visited 2
#define inf 10e+9
#define pb push_back
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 300005
#define MAX2 2000005
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
const int sz=1000000;
ll stree[sz]={0};
void buildtree(ll start,ll low,ll high,ll arr[]){
    if (low>high)
        return;
    if(low==high){
        stree[start]=arr[low];
        return;
    }
    ll left=2*start,right=left+1,mid=(low+high)/2;
    buildtree(left,low,mid,arr);
    buildtree(right,mid+1,high,arr);
    stree[start]=min(stree[left],stree[right]);
}

ll query(ll start,ll low,ll high,ll u,ll v){
    if(low>high||u>v||low>v||high<u)
        return nil;
    if(low>=u&&high<=v)
        return stree[start];
    ll left=2*start,right=left+1,mid=(low+high)/2;
    return min(query(left,low,mid,u,v),query(right,mid+1,high,u,v));
}
int main(){
   ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

   int t;
   cin>>t;
   while(t--){
	   ll n;
	   cin>>n;
	   ll arr[n];
	   for(int i=0;i<n;++i)
	     cin>>arr[i];
	   for(int i=0;i<5*n;++i)
	   	stree[i]=1000000010;
	   ll l[n],r[n];
	   l[0]=arr[0];
	   for(int i=1;i<n;++i)
	   	l[i]=max(l[i-1],arr[i]);
	   r[n-1]=arr[n-1];
	   for(int i=n-2;i>=0;--i)
	   	r[i]=max(r[i+1],arr[i]);
	   // for(int i=0;i<n;++i)
	   // 	cout<<l[i]<<" ";
	   // cout<<endl;
	   // for(int i=0;i<n;++i)
	   // 	cout<<r[i]<<" ";
	   // cout<<endl;
	   buildtree(1,0,n-1,arr);
	   string ans="NO";
	   ll i=0,j=n-1;
	   while(i+1<j){
	   	ll val=query(1,0,n-1,i+1,j-1);
	   	// cout<<i<<" "<<j<<" "<<val<<endl;
	   	if(val==l[i] && val==r[j]){
	   		ans="YES";
	   		cout<<ans<<endl;
	   		cout<<i+1<<" "<<j-i-1<<" "<<n-j<<endl;
	   		break;
	   	}
	   	if(arr[i+1]<arr[j-1])
	   		++i;
	   	else if(arr[i+1]>arr[j-1])
	   		--j;
	   	else {
	   		++i;
	   		--j;
	   		while(i+1<j){
	   			if(r[j]<l[i])
	   				--j;
	   			else if(l[i]<r[j])
	   				++i;
	   			else
	   				break;
	   		}
	   	}
	   }
	   if(ans=="NO"){
	   	cout<<ans<<endl;
	   }
	}
   return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
				while(pos<n){
					ll val=query(1,1,n,i,pos-1);
					if(val==lmax[i-1]){
						cout<<"YES"<<endl;
						cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
						return;
					}
					pos++;
				}
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos==-1)
			continue;
		while(pos<n){
			ll val=query(1,1,n,i,pos-1);
			if(val==lmax[i-1]){
				cout<<"YES"<<endl;
				cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				return;
			}
			pos++;
		}

	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define db long double
#define rep(i,p,q) for(i=p;i<q;++i)
#define REP(i,p,q) for(i=p;i<=q;++i)
#define MOD 1000000007
#define stop return 0
#define pb push_back
#define nil 2000000010
#define initial 0
#define waiting 1
#define visited 2
#define inf 10e+9
#define pb push_back
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 300005
#define MAX2 2000005
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
const int sz=4000000;
ll stree[sz];
void buildtree(ll start,ll low,ll high,ll arr[]){
    if (low>high)
        return;
    if(low==high){
        stree[start]=arr[low];
        return;
    }
    ll left=2*start,right=left+1,mid=(low+high)/2;
    buildtree(left,low,mid,arr);
    buildtree(right,mid+1,high,arr);
    stree[start]=min(stree[left],stree[right]);
}

ll query(ll start,ll low,ll high,ll u,ll v){
    if(low>high||u>v||low>v||high<u)
        return nil;
    if(low>=u&&high<=v)
        return stree[start];
    ll left=2*start,right=left+1,mid=(low+high)/2;
    return min(query(left,low,mid,u,v),query(right,mid+1,high,u,v));
}
int main(){
   ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

   int t;
   cin>>t;
   while(t--){
	   ll n;
	   cin>>n;
	   ll arr[n];
	   for(int i=0;i<n;++i)
	     cin>>arr[i];
	   for(int i=0;i<10*n;++i)
	   	stree[i]=2000000010;
	   ll l[n],r[n];
	   l[0]=arr[0];
	   for(int i=1;i<n;++i)
	   	l[i]=max(l[i-1],arr[i]);
	   r[n-1]=arr[n-1];
	   for(int i=n-2;i>=0;--i)
	   	r[i]=max(r[i+1],arr[i]);
	   buildtree(1,0,n-1,arr);
	   string ans="NO";
	   ll i=0,j=n-1;
	   while(i+1<j){
	   	ll val=query(1,0,n-1,i+1,j-1);
	   	// cout<<i<<" "<<j<<" "<<val<<endl;
	   	if(val==l[i] && val==r[j]){
	   		ans="YES";
	   		cout<<ans<<endl;
	   		ll lf=i+1;
	   		ll mid=j-i-1;
	   		ll rig=n-j;
	   		assert(lf+mid+rig==n);
	   		cout<<i+1<<" "<<j-i-1<<" "<<n-j<<endl;
	   		break;
	   	}
	   	if(l[i]==r[j]){
		   	if(arr[i+1]<arr[j-1])
		   		++i;
		   	else
		   		--j;
		 }
		 else if(l[i]>r[j])
		 	--j;
		 else
		 	++i;
	   }
	   if(ans=="YES")
	   	continue;
	   i=0,j=n-1;
	   while(i+1<j){
	   	ll val=query(1,0,n-1,i+1,j-1);
	   	// cout<<i<<" "<<j<<" "<<val<<endl;
	   	if(val==l[i] && val==r[j]){
	   		ans="YES";
	   		cout<<ans<<endl;
	   		ll lf=i+1;
	   		ll mid=j-i-1;
	   		ll rig=n-j;
	   		assert(lf+mid+rig==n);
	   		cout<<i+1<<" "<<j-i-1<<" "<<n-j<<endl;
	   		break;
	   	}
	   	if(l[i]==r[j]){
		   	if(arr[i+1]>arr[j-1])
		   		++i;
		   	else
		   		--j;
		 }
		 else if(l[i]>r[j])
		 	--j;
		 else
		 	++i;
	   }
	   if(ans=="YES")
	   	continue;
	   i=0,j=n-1;
	   while(i+1<j){
	   	ll val=query(1,0,n-1,i+1,j-1);
	   	// cout<<i<<" "<<j<<" "<<val<<endl;
	   	if(val==l[i] && val==r[j]){
	   		ans="YES";
	   		cout<<ans<<endl;
	   		ll lf=i+1;
	   		ll mid=j-i-1;
	   		ll rig=n-j;
	   		assert(lf+mid+rig==n);
	   		cout<<i+1<<" "<<j-i-1<<" "<<n-j<<endl;
	   		break;
	   	}
	   	if(l[i]==r[j]){
		   	if(arr[i+1]>arr[j-1])
		   		++i;
		   	else
		   		--j;
		 }
		 else if(l[i]<r[j])
		 	--j;
		 else
		 	++i;
	   }
	   if(ans=="NO"){
	   	cout<<ans<<endl;
	   }
	}
   return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	// cout<<vec<<endl;
	// cout<<lmax<<endl;
	// cout<<rmax<<endl;
	for(int i=2;i<n;++i){
		int low=i,high=n-1,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			int val=query(1,1,n,i,mid);
			// cout<<i<<" "<<mid<<" "<<val<<endl;
			if(val==lmax[i-1]){
				pos=mid;
				low=mid+1;
				// cout<<i<<" "<<pos<<endl;
				if(pos!=-1 && lmax[i-1]==rmax[pos+1]){
					cout<<"YES"<<endl;
					cout<<i-1<<" "<<pos-i+1<<" "<<n-pos<<endl;
					return;
				}
			}
			else if(val<lmax[i-1]){
				high=mid-1;
			}
			else{
				high=mid-1;
			}
		}
		low=i,high=n-1,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			int val=query(1,1,n,i,mid);
			// cout<<i<<" "<<mid<<" "<<val<<endl;
			if(val==lmax[i-1]){
				pos=mid;
				high=mid-1;
				// cout<<i<<" "<<pos<<endl;
				if(pos!=-1 && lmax[i-1]==rmax[pos+1]){
					cout<<"YES"<<endl;
					cout<<i-1<<" "<<pos-i+1<<" "<<n-pos<<endl;
					return;
				}
			}
			else if(val<lmax[i-1]){
				high=mid-1;
			}
			else{
				low=mid+1;
			}
		}
	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
				// while(pos<=n){
				// 	ll val=query(1,1,n,i,pos-1);
				// 	if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
				// 		cout<<"YES"<<endl;
				// 		cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				// 		return;
				// 	}
				// 	pos++;
				// }
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos==-1)
			continue;
		while(pos<=n){
			ll val=query(1,1,n,i,pos-1);
			if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
				cout<<"YES"<<endl;
				cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				return;
			}
			if(rmax[pos]<val)
				break;
			pos++;
		}

	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define db long double
#define rep(i,p,q) for(i=p;i<q;++i)
#define REP(i,p,q) for(i=p;i<=q;++i)
#define MOD 1000000007
#define stop return 0
#define pb push_back
#define nil 2000000010
#define initial 0
#define waiting 1
#define visited 2
#define inf 10e+9
#define pb push_back
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 300005
#define MAX2 2000005
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
const int sz=4000000;
ll stree[sz];
void buildtree(ll start,ll low,ll high,ll arr[]){
    if (low>high)
        return;
    if(low==high){
        stree[start]=arr[low];
        return;
    }
    ll left=2*start,right=left+1,mid=(low+high)/2;
    buildtree(left,low,mid,arr);
    buildtree(right,mid+1,high,arr);
    stree[start]=min(stree[left],stree[right]);
}

ll query(ll start,ll low,ll high,ll u,ll v){
    if(low>high||u>v||low>v||high<u)
        return nil;
    if(low>=u&&high<=v)
        return stree[start];
    ll left=2*start,right=left+1,mid=(low+high)/2;
    return min(query(left,low,mid,u,v),query(right,mid+1,high,u,v));
}
int main(){
   ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

   int t;
   cin>>t;
   while(t--){
	   ll n;
	   cin>>n;
	   ll arr[n];
	   for(int i=0;i<n;++i)
	     cin>>arr[i];
	   for(int i=0;i<10*n;++i)
	   	stree[i]=2000000010;
	   ll l[n],r[n];
	   l[0]=arr[0];
	   for(int i=1;i<n;++i)
	   	l[i]=max(l[i-1],arr[i]);
	   r[n-1]=arr[n-1];
	   for(int i=n-2;i>=0;--i)
	   	r[i]=max(r[i+1],arr[i]);
	   buildtree(1,0,n-1,arr);
	   string ans="NO";
	   ll i=0,j=n-1;
	   while(i+1<j){
	   	ll val=query(1,0,n-1,i+1,j-1);
	   	// cout<<i<<" "<<j<<" "<<val<<endl;
	   	if(val==l[i] && val==r[j]){
	   		ans="YES";
	   		cout<<ans<<endl;
	   		ll lf=i+1;
	   		ll mid=j-i-1;
	   		ll rig=n-j;
	   		assert(lf+mid+rig==n);
	   		cout<<i+1<<" "<<j-i-1<<" "<<n-j<<endl;
	   		break;
	   	}
	   	if(l[i]==r[j]){
		   	if(arr[i+1]<arr[j-1])
		   		++i;
		   	else if(arr[i+1]>arr[j-1])
		   		--j;
		   	else{
		   		++i;
		   		--j;
		   	}
		 }
		 else if(l[i]>r[j])
		 	--j;
		 else
		 	++i;
	   }
	   if(ans=="YES")
	   	continue;
	   i=0,j=n-1;
	   while(i+1<j){
	   	ll val=query(1,0,n-1,i+1,j-1);
	   	// cout<<i<<" "<<j<<" "<<val<<endl;
	   	if(val==l[i] && val==r[j]){
	   		ans="YES";
	   		cout<<ans<<endl;
	   		ll lf=i+1;
	   		ll mid=j-i-1;
	   		ll rig=n-j;
	   		assert(lf+mid+rig==n);
	   		cout<<i+1<<" "<<j-i-1<<" "<<n-j<<endl;
	   		break;
	   	}
	   	if(l[i]==r[j]){
		   	if(arr[i+1]>arr[j-1])
		   		++i;
		   	else if(arr[i+1]<arr[j-1])
		   		--j;
		   	else{
		   		++i;
		   		--j;
		   	}
		 }
		 else if(l[i]>r[j])
		 	--j;
		 else
		 	++i;
	   }
	   if(ans=="YES")
	   	continue;
	   i=0,j=n-1;
	   while(i+1<j){
	   	ll val=query(1,0,n-1,i+1,j-1);
	   	// cout<<i<<" "<<j<<" "<<val<<endl;
	   	if(val==l[i] && val==r[j]){
	   		ans="YES";
	   		cout<<ans<<endl;
	   		ll lf=i+1;
	   		ll mid=j-i-1;
	   		ll rig=n-j;
	   		assert(lf+mid+rig==n);
	   		cout<<i+1<<" "<<j-i-1<<" "<<n-j<<endl;
	   		break;
	   	}
	   	if(l[i]==r[j]){
		   	if(arr[i+1]>arr[j-1])
		   		++i;
		   	else if(arr[i+1]<arr[j-1])
		   		--j;
		   	else{
		   		++i;
		   		--j;
		   	}
		 }
		 else if(l[i]<r[j])
		 	--j;
		 else
		 	++i;
	   }
	   if(ans=="NO"){
	   	cout<<ans<<endl;
	   }
	}
   return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	// cout<<vec<<endl;
	// cout<<lmax<<endl;
	// cout<<rmax<<endl;
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos!=-1 && query(1,1,n,i,pos-1)==lmax[i-1]){
			cout<<"YES"<<endl;
			cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
			return;
		}
	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 2e9;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos==-1)
			continue;
		while(pos<=n){
			ll val=query(1,1,n,i,pos-1);
			if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
				cout<<"YES"<<endl;
				cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				return;
			}
			if(rmax[pos]<lmax[i-1] || val<lmax[i-1])
				break;
			pos++;
		}

	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
				while(pos<=n){
					ll val=query(1,1,n,i,pos-1);
					if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
						cout<<"YES"<<endl;
						cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
						return;
					}
					if(rmax[pos]<lmax[i-1])
						break;
					pos++;
				}
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos==-1)
			continue;
		while(pos<=n){
			ll val=query(1,1,n,i,pos-1);
			if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
				cout<<"YES"<<endl;
				cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				return;
			}
			if(rmax[pos]<lmax[i-1])
				break;
			pos++;
		}

	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define db long double
#define rep(i,p,q) for(i=p;i<q;++i)
#define REP(i,p,q) for(i=p;i<=q;++i)
#define MOD 1000000007
#define stop return 0
#define pb push_back
#define nil 1000000010
#define initial 0
#define waiting 1
#define visited 2
#define inf 10e+9
#define pb push_back
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 300005
#define MAX2 2000005
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
const int sz=1000000;
ll stree[sz]={0};
void buildtree(ll start,ll low,ll high,ll arr[]){
    if (low>high)
        return;
    if(low==high){
        stree[start]=arr[low];
        return;
    }
    ll left=2*start,right=left+1,mid=(low+high)/2;
    buildtree(left,low,mid,arr);
    buildtree(right,mid+1,high,arr);
    stree[start]=min(stree[left],stree[right]);
}

ll query(ll start,ll low,ll high,ll u,ll v){
    if(low>high||u>v||low>v||high<u)
        return nil;
    if(low>=u&&high<=v)
        return stree[start];
    ll left=2*start,right=left+1,mid=(low+high)/2;
    return min(query(left,low,mid,u,v),query(right,mid+1,high,u,v));
}
int main(){
   ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

   int t;
   cin>>t;
   while(t--){
	   ll n;
	   cin>>n;
	   ll arr[n];
	   for(int i=0;i<n;++i)
	     cin>>arr[i];
	   for(int i=0;i<sz;++i)
	   	stree[i]=1000000010;
	   ll l[n],r[n];
	   l[0]=arr[0];
	   for(int i=1;i<n;++i)
	   	l[i]=max(l[i-1],arr[i]);
	   r[n-1]=arr[n-1];
	   for(int i=n-2;i>=0;--i)
	   	r[i]=max(r[i+1],arr[i]);
	   // for(int i=0;i<n;++i)
	   // 	cout<<l[i]<<" ";
	   // cout<<endl;
	   // for(int i=0;i<n;++i)
	   // 	cout<<r[i]<<" ";
	   // cout<<endl;
	   buildtree(1,0,n-1,arr);
	   string ans="NO";
	   ll i=0,j=n-1;
	   while(i+1<j){
	   	ll val=query(1,0,n-1,i+1,j-1);
	   	// cout<<i<<" "<<j<<" "<<val<<endl;
	   	if(val==l[i] && val==r[j]){
	   		ans="YES";
	   		cout<<ans<<endl;
	   		cout<<i+1<<" "<<j-i-1<<" "<<n-j<<endl;
	   		break;
	   	}
	   	if(arr[i+1]<arr[j-1])
	   		++i;
	   	else if(arr[i+1]>arr[j-1])
	   		--j;
	   	else {
	   		++i;
	   		--j;
	   		while(i+1<j){
	   			if(r[j]<l[i])
	   				--j;
	   			else if(l[i]<r[j])
	   				++i;
	   			else
	   				break;
	   		}
	   	}
	   }
	   if(ans=="NO"){
	   	cout<<ans<<endl;
	   }
	}
   return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define db long double
#define rep(i,p,q) for(i=p;i<q;++i)
#define REP(i,p,q) for(i=p;i<=q;++i)
#define MOD 1000000007
#define stop return 0
#define pb push_back
#define nil 2000000010
#define initial 0
#define waiting 1
#define visited 2
#define inf 10e+9
#define pb push_back
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 300005
#define MAX2 2000005
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
const int sz=4000000;
ll stree[sz];
void buildtree(ll start,ll low,ll high,ll arr[]){
    if (low>high)
        return;
    if(low==high){
        stree[start]=arr[low];
        return;
    }
    ll left=2*start,right=left+1,mid=(low+high)/2;
    buildtree(left,low,mid,arr);
    buildtree(right,mid+1,high,arr);
    stree[start]=min(stree[left],stree[right]);
}

ll query(ll start,ll low,ll high,ll u,ll v){
    if(low>high||u>v||low>v||high<u)
        return nil;
    if(low>=u&&high<=v)
        return stree[start];
    ll left=2*start,right=left+1,mid=(low+high)/2;
    return min(query(left,low,mid,u,v),query(right,mid+1,high,u,v));
}
int main(){
   ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

   int t;
   cin>>t;
   while(t--){
	   ll n;
	   cin>>n;
	   ll arr[n];
	   for(int i=0;i<n;++i)
	     cin>>arr[i];
	   for(int i=0;i<10*n;++i)
	   	stree[i]=2000000010;
	   ll l[n],r[n];
	   l[0]=arr[0];
	   for(int i=1;i<n;++i)
	   	l[i]=max(l[i-1],arr[i]);
	   r[n-1]=arr[n-1];
	   for(int i=n-2;i>=0;--i)
	   	r[i]=max(r[i+1],arr[i]);
	   buildtree(1,0,n-1,arr);
	   string ans="NO";
	   ll i=0,j=n-1;
	   while(i+1<j){
	   	ll val=query(1,0,n-1,i+1,j-1);
	   	// cout<<i<<" "<<j<<" "<<val<<endl;
	   	if(val==l[i] && val==r[j]){
	   		ans="YES";
	   		cout<<ans<<endl;
	   		ll lf=i+1;
	   		ll mid=j-i-1;
	   		ll rig=n-j;
	   		assert(lf+mid+rig==n);
	   		cout<<i+1<<" "<<j-i-1<<" "<<n-j<<endl;
	   		break;
	   	}
	   	if(l[i]==r[j]){
		   	if(arr[i+1]<arr[j-1])
		   		++i;
		   	else if(arr[i+1]>arr[j-1])
		   		--j;
		   	else{
		   		++i;
		   		--j;
		   	}
		 }
		 else if(l[i]>r[j])
		 	--j;
		 else
		 	++i;
	   }
	   if(ans=="NO"){
	   	cout<<ans<<endl;
	   }
	}
   return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
				// while(pos<=n){
				// 	ll val=query(1,1,n,i,pos-1);
				// 	if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
				// 		cout<<"YES"<<endl;
				// 		cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				// 		return;
				// 	}
				// 	pos++;
				// }
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos==-1)
			continue;
		while(pos<=n){
			ll val=query(1,1,n,i,pos-1);
			if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
				cout<<"YES"<<endl;
				cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				return;
			}
			if(rmax[pos]<lmax[i-1])
				break;
			pos++;
		}

	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos==-1)
			continue;
		while(pos<n){
			ll val=query(1,1,n,i,pos-1);
			if(val==lmax[i-1]){
				cout<<"YES"<<endl;
				cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				return;
			}
			pos++;
		}

	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define db long double
#define rep(i,p,q) for(i=p;i<q;++i)
#define REP(i,p,q) for(i=p;i<=q;++i)
#define MOD 1000000007
#define stop return 0
#define pb push_back
#define nil 2000000010
#define initial 0
#define waiting 1
#define visited 2
#define inf 10e+9
#define pb push_back
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 300005
#define MAX2 2000005
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
const int sz=4000000;
ll stree[sz];
void buildtree(ll start,ll low,ll high,ll arr[]){
    if (low>high)
        return;
    if(low==high){
        stree[start]=arr[low];
        return;
    }
    ll left=2*start,right=left+1,mid=(low+high)/2;
    buildtree(left,low,mid,arr);
    buildtree(right,mid+1,high,arr);
    stree[start]=min(stree[left],stree[right]);
}

ll query(ll start,ll low,ll high,ll u,ll v){
    if(low>high||u>v||low>v||high<u)
        return nil;
    if(low>=u&&high<=v)
        return stree[start];
    ll left=2*start,right=left+1,mid=(low+high)/2;
    return min(query(left,low,mid,u,v),query(right,mid+1,high,u,v));
}
int main(){
   ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

   int t;
   cin>>t;
   while(t--){
	   ll n;
	   cin>>n;
	   ll arr[n];
	   for(int i=0;i<n;++i)
	     cin>>arr[i];
	   for(int i=0;i<5*n;++i)
	   	stree[i]=2000000010;
	   ll l[n],r[n];
	   l[0]=arr[0];
	   for(int i=1;i<n;++i)
	   	l[i]=max(l[i-1],arr[i]);
	   r[n-1]=arr[n-1];
	   for(int i=n-2;i>=0;--i)
	   	r[i]=max(r[i+1],arr[i]);
	   buildtree(1,0,n-1,arr);
	   string ans="NO";
	   ll i=0,j=n-1;
	   while(i+1<j){
	   	ll val=query(1,0,n-1,i+1,j-1);
	   	// cout<<i<<" "<<j<<" "<<val<<endl;
	   	if(val==l[i] && val==r[j]){
	   		ans="YES";
	   		cout<<ans<<endl;
	   		ll lf=i+1;
	   		ll mid=j-i-1;
	   		ll rig=n-j;
	   		assert(lf+mid+rig==n);
	   		cout<<i+1<<" "<<j-i-1<<" "<<n-j<<endl;
	   		break;
	   	}
	   	if(arr[i+1]<arr[j-1])
	   		++i;
	   	else if(arr[i+1]>arr[j-1])
	   		--j;
	   	else{
	   		++i;
	   		--j;
	   	}
	   }
	   if(ans=="NO"){
	   	cout<<ans<<endl;
	   }
	}
   return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl '\n';
#define pb push_back
#define mod 1000000007
#define ll long long int
#define all(x) x.begin(),x.end()
#define prn(x) cerr<<x<<endl;
using namespace std;
const int N = 1000005;
#define test_case 1
ll tree[N];
vector<ll> vec;

void build(ll v,ll tl,ll tr){
	if(tl==tr)
		tree[v]=vec[tl];
	else{
		ll tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		tree[v]=min(tree[2*v],tree[2*v+1]);
	}
}

ll query(ll v,ll tl,ll tr,ll l,ll r){
	if(l>r)
		return 1e15;
	if(tl==l && tr==r)
		return tree[v];
	else{
		ll tm=(tl+tr)/2;
		return min(query(2*v,tl,tm,l,min(tm,r)),query(2*v+1,tm+1,tr,max(l,tm+1),r));
	}
}

void solution(){
	int n;
	cin>>n;
	vec.clear();
	vec.resize(n+1);
	vector<ll> lmax(n+1,0),rmax(n+1,0);
	for(int i=1;i<=n;++i){
		cin>>vec[i];
		lmax[i]=max(lmax[i-1],vec[i]);
	}
	rmax[n]=vec[n];
	for(int i=n-1;i>0;--i){
		rmax[i]=max(rmax[i+1],vec[i]);
	}
	build(1,1,n);
	for(int i=2;i<n;++i){
		int low=i+1,high=n,pos=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(rmax[mid]==lmax[i-1]){
				pos=mid;
				high=mid-1;
				while(pos<=n){
					ll val=query(1,1,n,i,pos-1);
					if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
						cout<<"YES"<<endl;
						cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
						return;
					}
					pos++;
				}
			}
			else if(rmax[mid]<lmax[i-1]){
				high=mid-1;
			}
			else
				low=mid+1;
		}
		if(pos==-1)
			continue;
		while(pos<=n){
			ll val=query(1,1,n,i,pos-1);
			if(val==lmax[i-1] && lmax[i-1]==rmax[pos]){
				cout<<"YES"<<endl;
				cout<<i-1<<" "<<pos-i<<" "<<n-pos+1<<endl;
				return;
			}
			pos++;
		}

	}
	cout<<"NO"<<endl;
}

int main(){
	#ifdef LOCAL
		freopen("in.txt" , "r" , stdin);
	#else
		ios_base::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	#endif
	int t=1;
	if(test_case)	cin>>t;
	while(t--)		solution();
	return 0;
}


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

#define eb emplace_back
#define pb push_back
#define INF LLONG_MAX
#define FLT_INF pow(10.0, 16)

using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A>
string to_string(const A &v);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(char c) { return string(1, c); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(const pair<A, B> &p)
{
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(const tuple<A, B, C> &p)
{
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) + ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A>
string to_string(const A &v)
{
  bool first = true;
  string res = "{";
  for (const auto &x : v)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T> &val)
{
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T> &val)
{
  reverse(val.begin(), val.end());
}

template <typename T>
void reverse(map<T, T> &val)
{
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T> &val)
{
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T> &val)
{
  return val.first + val.second;
}

template <typename T>
T min(T a, T b, T c)
{
  return min(min(a, b), c);
}

template <typename T>
T max(T a, T b, T c)
{
  return max(max(a, b), c);
}

template <typename T>
T mul_mod(T a, T b, T mod)
{
  T res = 0;
  a %= mod;
  while (b)
  {
    if (b & 1)
    {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

template <typename T>
T fac_mod(T v, T mod)
{
  ll res = 1;
  for (ll i = 1; i <= v; i++)
  {
    res *= i;
    res = res % mod;
  }
  return res;
}

template <typename T>
T pow_mod(T v, T p, T mod)
{
  if (p == 1)
    return v;

  if (p % 2 == 0)
  {
    T t = pow_mod(v, p / 2, mod);
    return (t * t) % mod;
  }
  else
  {
    return (v * pow_mod(v, p - 1, mod)) % mod;
  }
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define COMMON_MOD static_cast<ll>(pow(10, 9) + 7)
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
sort(a.begin(), a.end(), [ ](ll& lhs, ll& rhs) {return abs(lhs) < abs(rhs);});
*/

class mytask
{
public:
  mytask() {}
  vll find_circle(ll i, ll parent, vector<vll> &t, ll depth, vll &t_depth)
  {
    t_depth[i] = depth;
    for (ll ch : t[i])
    {
      if (ch == parent)
        continue;

      if (t_depth[ch] != -1)
      {
        return {ch, i};
      }

      vll res = find_circle(ch, i, t, depth + 1, t_depth);
      if (res.size() > 0)
      {
        res.pb(i);
        return res;
      }
    }

    return {};
  }

  int solve()
  {

    ll t;
    cin >> t;
    while (t--)
    {
      ll n;
      cin >> n;
      vll a(n);
      for (ll &v : a)
        cin >> v;
      bool good = false;
      ll max_x = a[0];

      for (ll x = 1; x < n - 2; x++)
      {
        max_x = max(max_x, a[x - 1]);
        ll max_z = a.back();
        for (ll y = n - x - 1; y > 0; y--)
        {
          max_z = max(max_z, a[x + y]);
          //debug(max_z, x, y);
          if (max_z > max_x)
            break;
          if (max_x == max_z)
          {
            ll min_y = 1e10;
            for (ll i = x; i < x + y; i++)
            {
              min_y = min(min_y, a[i]);
              debug(x, y, min_y, max_x, max_z, a[x + y], i);
              if (min_y < max_x)
              {
                break;
              }
            }
            if (min_y == max_x)
            {
              good = true;
              cout << "YES"
                   << "\n";
              cout << x << " " << y << " " << n - x - y;
              break;
            }
          }
        }
        if (good)
          break;
      }
      if (!good)
        cout << "NO";
      cout << "\n";
    }
    return 0;
  }
};

int main()
{

  auto task = mytask();
  task.solve();

  return 0;
}


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

#define eb emplace_back
#define pb push_back
#define INF LLONG_MAX
#define FLT_INF pow(10.0, 16)

using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A>
string to_string(const A &v);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(char c) { return string(1, c); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(const pair<A, B> &p)
{
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(const tuple<A, B, C> &p)
{
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) + ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A>
string to_string(const A &v)
{
  bool first = true;
  string res = "{";
  for (const auto &x : v)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T> &val)
{
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T> &val)
{
  reverse(val.begin(), val.end());
}

template <typename T>
void reverse(map<T, T> &val)
{
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T> &val)
{
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T> &val)
{
  return val.first + val.second;
}

template <typename T>
T min(T a, T b, T c)
{
  return min(min(a, b), c);
}

template <typename T>
T max(T a, T b, T c)
{
  return max(max(a, b), c);
}

template <typename T>
T mul_mod(T a, T b, T mod)
{
  T res = 0;
  a %= mod;
  while (b)
  {
    if (b & 1)
    {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

template <typename T>
T fac_mod(T v, T mod)
{
  ll res = 1;
  for (ll i = 1; i <= v; i++)
  {
    res *= i;
    res = res % mod;
  }
  return res;
}

template <typename T>
T pow_mod(T v, T p, T mod)
{
  if (p == 1)
    return v;

  if (p % 2 == 0)
  {
    T t = pow_mod(v, p / 2, mod);
    return (t * t) % mod;
  }
  else
  {
    return (v * pow_mod(v, p - 1, mod)) % mod;
  }
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define COMMON_MOD static_cast<ll>(pow(10, 9) + 7)
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
sort(a.begin(), a.end(), [ ](ll& lhs, ll& rhs) {return abs(lhs) < abs(rhs);});
*/

class mytask
{
public:
  mytask() {}
  vll find_circle(ll i, ll parent, vector<vll> &t, ll depth, vll &t_depth)
  {
    t_depth[i] = depth;
    for (ll ch : t[i])
    {
      if (ch == parent)
        continue;

      if (t_depth[ch] != -1)
      {
        return {ch, i};
      }

      vll res = find_circle(ch, i, t, depth + 1, t_depth);
      if (res.size() > 0)
      {
        res.pb(i);
        return res;
      }
    }

    return {};
  }

  int solve()
  {

    ll t;
    cin >> t;
    while (t--)
    {
      ll n;
      cin >> n;
      vll a(n);
      for (ll &v : a)
        cin >> v;
      bool good = false;
      ll max_x = a[0];

      for (ll x = 1; x <= n - 2; x++)
      {
        max_x = max(max_x, a[x - 1]);
        ll max_z = a.back();
        for (ll y = n - x - 1; y > 0; y--)
        {
          max_z = max(max_z, a[x + y]);
          //debug(max_z, x, y);
          if (max_z > max_x)
            break;
          if (max_x == max_z)
          {
            ll min_y = 1e10;
            for (ll i = x; i < x + y; i++)
            {
              min_y = min(min_y, a[i]);
              //debug(x, y, min_y, max_x, max_z, a[x + y], i);
              if (min_y < max_x)
              {
                break;
              }
            }
            if (min_y == max_x)
            {
              good = true;
              cout << "YES"
                   << "\n";
              cout << x << " " << y << " " << n - x - y;
              break;
            }
          }
        }
        if (good)
          break;
      }
      if (!good)
        cout << "NO";
      cout << "\n";
    }
    return 0;
  }
};

int main()
{

  auto task = mytask();
  task.solve();

  return 0;
}


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

#define eb emplace_back
#define pb push_back
#define INF LLONG_MAX
#define FLT_INF pow(10.0, 16)

using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A>
string to_string(const A &v);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(char c) { return string(1, c); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(const pair<A, B> &p)
{
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(const tuple<A, B, C> &p)
{
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) + ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A>
string to_string(const A &v)
{
  bool first = true;
  string res = "{";
  for (const auto &x : v)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T> &val)
{
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T> &val)
{
  reverse(val.begin(), val.end());
}

template <typename T>
void reverse(map<T, T> &val)
{
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T> &val)
{
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T> &val)
{
  return val.first + val.second;
}

template <typename T>
T min(T a, T b, T c)
{
  return min(min(a, b), c);
}

template <typename T>
T max(T a, T b, T c)
{
  return max(max(a, b), c);
}

template <typename T>
T mul_mod(T a, T b, T mod)
{
  T res = 0;
  a %= mod;
  while (b)
  {
    if (b & 1)
    {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

template <typename T>
T fac_mod(T v, T mod)
{
  ll res = 1;
  for (ll i = 1; i <= v; i++)
  {
    res *= i;
    res = res % mod;
  }
  return res;
}

template <typename T>
T pow_mod(T v, T p, T mod)
{
  if (p == 1)
    return v;

  if (p % 2 == 0)
  {
    T t = pow_mod(v, p / 2, mod);
    return (t * t) % mod;
  }
  else
  {
    return (v * pow_mod(v, p - 1, mod)) % mod;
  }
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define COMMON_MOD static_cast<ll>(pow(10, 9) + 7)
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
sort(a.begin(), a.end(), [ ](ll& lhs, ll& rhs) {return abs(lhs) < abs(rhs);});
*/
class segtree
{
public:
  vll t;
  ll size;
  segtree(vll &a)
  {
    size = 1;
    while (size < a.size())
      size *= 2;
    t.assign(2 * size - 1, 1e6);
    fill(a, 0, 0, size);
  }

  void fill(vll &a, ll x, ll lx, ll rx)
  {
    if (lx >= a.size())
      return;
    if (rx - lx == 1)
    {
      t[x] = a[lx];
      return;
    }

    ll m = (lx + rx) / 2;
    fill(a, 2 * x + 1, lx, m);
    fill(a, 2 * x + 2, m, rx);

    t[x] = min(t[2 * x + 1], t[2 * x + 2]);
  }
  ll get_min(ll l, ll r, ll x, ll lx, ll rx)
  {
    if (rx - lx == 1)
    {

      if (lx >= l && rx <= r)
        return t[x];
      else
        return 1e10;
    }
    if (lx > r || rx < l)
      return 1e10;
    if (lx >= l && rx <= r)
      return t[x];

    ll m = (lx + rx) / 2;
    return min(get_min(l, r, 2 * x + 1, lx, m), get_min(l, r, 2 * x + 2, m, rx));
  }
  ll get_min(ll l, ll r)
  {
    return get_min(l, r, 0, 0, size);
  }
};

class mytask
{
public:
  mytask() {}
  int solve()
  {

    ll t;
    cin >> t;
    while (t--)
    {
      ll n;
      cin >> n;
      vll a(n);
      for (ll &v : a)
        cin >> v;

      segtree t(a);
      bool good = false;
      ll max_x = a[0];

      for (ll x = 1; x <= n - 2; x++)
      {
        max_x = max(max_x, a[x - 1]);
        ll r = n - 1;
        ll max_z = a[n - 1];
        ll last_max_z = 0;
        while (r > x && max_x >= a[r])
        {
          last_max_z = max(last_max_z, max_z);
          max_z = max(max_z, a[r]);
          r--;
        }
        r++;
        if (max_z < max_x)
          continue;
        debug(x, r);
        ll min_y = t.get_min(x, r);
        debug(min_y);
        if (min_y < max_x)
          continue;
        if (min_y > max_x && r < n - 1 && last_max_z == max_x)
        {
          r++;
          min_y = t.get_min(x, r);
        }
        if (min_y == max_x)
        {
          cout << "YES"
               << "\n";
          cout << x << " " << r - x << " " << n - r;
          good = true;
        }

        // for (ll y = n - x - 1; y > 0; y--)
        // {
        //   max_z = max(max_z, a[x + y]);
        //   //debug(max_z, x, y);
        //   if (max_z > max_x)
        //     break;
        //   if (max_x == max_z)
        //   {
        //     ll min_y = t.get_min(x, x + y);
        //     //debug(t.t);
        //     // ll min_y = 1e10;
        //     // for (ll i = x; i < x + y; i++)
        //     // {
        //     //   min_y = min(min_y, a[i]);
        //     //   //debug(x, y, min_y, max_x, max_z, a[x + y], i);
        //     //   if (min_y < max_x)
        //     //   {
        //     //     break;
        //     //   }
        //     // }
        //     if (min_y == max_x)
        //     {
        //       good = true;
        //       cout << "YES"
        //            << "\n";
        //       cout << x << " " << y << " " << n - x - y;
        //       break;
        //     }
        //     else if (min_y > max_x)
        //     {
        //       break;
        //     }
        //   }

        if (good)
          break;
      }
      if (!good)
        cout << "NO";
      cout << "\n";
    }
    return 0;
  }
};

int main()
{

  auto task = mytask();
  task.solve();

  return 0;
}


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

#define eb emplace_back
#define pb push_back
#define INF LLONG_MAX
#define FLT_INF pow(10.0, 16)

using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A>
string to_string(const A &v);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(char c) { return string(1, c); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(const pair<A, B> &p)
{
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(const tuple<A, B, C> &p)
{
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) + ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A>
string to_string(const A &v)
{
  bool first = true;
  string res = "{";
  for (const auto &x : v)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T> &val)
{
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T> &val)
{
  reverse(val.begin(), val.end());
}

template <typename T>
void reverse(map<T, T> &val)
{
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T> &val)
{
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T> &val)
{
  return val.first + val.second;
}

template <typename T>
T min(T a, T b, T c)
{
  return min(min(a, b), c);
}

template <typename T>
T max(T a, T b, T c)
{
  return max(max(a, b), c);
}

template <typename T>
T mul_mod(T a, T b, T mod)
{
  T res = 0;
  a %= mod;
  while (b)
  {
    if (b & 1)
    {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

template <typename T>
T fac_mod(T v, T mod)
{
  ll res = 1;
  for (ll i = 1; i <= v; i++)
  {
    res *= i;
    res = res % mod;
  }
  return res;
}

template <typename T>
T pow_mod(T v, T p, T mod)
{
  if (p == 1)
    return v;

  if (p % 2 == 0)
  {
    T t = pow_mod(v, p / 2, mod);
    return (t * t) % mod;
  }
  else
  {
    return (v * pow_mod(v, p - 1, mod)) % mod;
  }
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define COMMON_MOD static_cast<ll>(pow(10, 9) + 7)
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
sort(a.begin(), a.end(), [ ](ll& lhs, ll& rhs) {return abs(lhs) < abs(rhs);});
*/
class segtree
{
public:
  vll t;
  ll size;
  segtree(vll &a)
  {
    size = 1;
    while (size < a.size())
      size *= 2;
    t.assign(2 * size - 1, 1e6);
    fill(a, 0, 0, size);
  }

  void fill(vll &a, ll x, ll lx, ll rx)
  {
    if (lx >= a.size())
      return;
    if (rx - lx == 1)
    {
      t[x] = a[lx];
      return;
    }

    ll m = (lx + rx) / 2;
    fill(a, 2 * x + 1, lx, m);
    fill(a, 2 * x + 2, m, rx);

    t[x] = min(t[2 * x + 1], t[2 * x + 2]);
  }
  ll get_min(ll l, ll r, ll x, ll lx, ll rx)
  {
    if (rx - lx == 1)
    {

      if (lx >= l && rx <= r)
        return t[x];
      else
        return 1e10;
    }
    if (lx > r || rx < l)
      return 1e10;
    if (lx >= l && rx <= r)
      return t[x];

    ll m = (lx + rx) / 2;
    return min(get_min(l, r, 2 * x + 1, lx, m), get_min(l, r, 2 * x + 2, m, rx));
  }
  ll get_min(ll l, ll r)
  {
    return get_min(l, r, 0, 0, size);
  }
};

class mytask
{
public:
  mytask() {}
  int solve()
  {

    ll t;
    cin >> t;
    while (t--)
    {
      ll n;
      cin >> n;
      vll a(n);
      for (ll &v : a)
        cin >> v;

      segtree t(a);
      bool good = false;
      ll max_x = a[0];

      for (ll x = 1; x <= n - 2; x++)
      {
        max_x = max(max_x, a[x - 1]);
        ll max_z = a.back();
        for (ll y = n - x - 1; y > 0; y--)
        {
          max_z = max(max_z, a[x + y]);
          //debug(max_z, x, y);
          if (max_z > max_x)
            break;
          if (max_x == max_z)
          {
            ll min_y = t.get_min(x, x + y);
            //debug(t.t);
            // ll min_y = 1e10;
            // for (ll i = x; i < x + y; i++)
            // {
            //   min_y = min(min_y, a[i]);
            //   //debug(x, y, min_y, max_x, max_z, a[x + y], i);
            //   if (min_y < max_x)
            //   {
            //     break;
            //   }
            // }
            if (min_y == max_x)
            {
              good = true;
              cout << "YES"
                   << "\n";
              cout << x << " " << y << " " << n - x - y;
              break;
            }
            else if (min_y > max_x)
            {
              break;
            }
          }
        }
        if (good)
          break;
      }
      if (!good)
        cout << "NO";
      cout << "\n";
    }
    return 0;
  }
};

int main()
{

  auto task = mytask();
  task.solve();

  return 0;
}


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

#define eb emplace_back
#define pb push_back
#define INF LLONG_MAX
#define FLT_INF pow(10.0, 16)

using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A>
string to_string(const A &v);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(char c) { return string(1, c); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(const pair<A, B> &p)
{
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(const tuple<A, B, C> &p)
{
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) + ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A>
string to_string(const A &v)
{
  bool first = true;
  string res = "{";
  for (const auto &x : v)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T> &val)
{
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T> &val)
{
  reverse(val.begin(), val.end());
}

template <typename T>
void reverse(map<T, T> &val)
{
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T> &val)
{
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T> &val)
{
  return val.first + val.second;
}

template <typename T>
T min(T a, T b, T c)
{
  return min(min(a, b), c);
}

template <typename T>
T max(T a, T b, T c)
{
  return max(max(a, b), c);
}

template <typename T>
T mul_mod(T a, T b, T mod)
{
  T res = 0;
  a %= mod;
  while (b)
  {
    if (b & 1)
    {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

template <typename T>
T fac_mod(T v, T mod)
{
  ll res = 1;
  for (ll i = 1; i <= v; i++)
  {
    res *= i;
    res = res % mod;
  }
  return res;
}

template <typename T>
T pow_mod(T v, T p, T mod)
{
  if (p == 1)
    return v;

  if (p % 2 == 0)
  {
    T t = pow_mod(v, p / 2, mod);
    return (t * t) % mod;
  }
  else
  {
    return (v * pow_mod(v, p - 1, mod)) % mod;
  }
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define COMMON_MOD static_cast<ll>(pow(10, 9) + 7)
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
sort(a.begin(), a.end(), [ ](ll& lhs, ll& rhs) {return abs(lhs) < abs(rhs);});
*/
class segtree
{
public:
  vll t;
  ll size;
  segtree(vll &a)
  {
    size = 1;
    while (size < a.size())
      size *= 2;
    t.assign(2 * size - 1, 1e6);
    fill(a, 0, 0, size);
  }

  void fill(vll &a, ll x, ll lx, ll rx)
  {
    if (lx >= a.size())
      return;
    if (rx - lx == 1)
    {
      t[x] = a[lx];
      return;
    }

    ll m = (lx + rx) / 2;
    fill(a, 2 * x + 1, lx, m);
    fill(a, 2 * x + 2, m, rx);

    t[x] = min(t[2 * x + 1], t[2 * x + 2]);
  }
  ll get_min(ll l, ll r, ll x, ll lx, ll rx)
  {
    if (rx - lx == 1)
    {

      if (lx >= l && rx <= r)
        return t[x];
      else
        return 1e10;
    }
    if (lx > r || rx < l)
      return 1e10;
    if (lx >= l && rx <= r)
      return t[x];

    ll m = (lx + rx) / 2;
    return min(get_min(l, r, 2 * x + 1, lx, m), get_min(l, r, 2 * x + 2, m, rx));
  }
  ll get_min(ll l, ll r)
  {
    return get_min(l, r, 0, 0, size);
  }
};

class mytask
{
public:
  mytask() {}
  int solve()
  {

    ll t;
    cin >> t;
    while (t--)
    {
      ll n;
      cin >> n;
      vll a(n);
      for (ll &v : a)
        cin >> v;

      segtree t(a);
      bool good = false;
      ll max_x = a[0];

      vll max_b(n);
      max_b[0] = a[n - 1];
      for (ll i = 1; i < n; i++)
      {
        max_b[i] = max(max_b[i - 1], a[n - 1 - i]);
      }
      debug(max_b);

      for (ll x = 1; x <= n - 2; x++)
      {
        max_x = max(max_x, a[x - 1]);
        //ll r = n - 1;
        //ll max_z = a[n - 1];
        // while (r > x && max_x >= a[r])
        // {
        //   last_max_z = max(last_max_z, max_z);
        //   max_z = max(max_z, a[r]);
        //   r--;
        // }
        debug(max_x);
        auto it = upper_bound(max_b.begin(), max_b.begin() + (n - x), max_x);
        //debug(max_x, it);
        if (it == max_b.begin())
          continue;
        it = prev(it);
        ll r = n - 1 - distance(max_b.begin(), it);
        if (r < x)
          continue;
        ll max_z = *it;
        debug(x, r, max_z);
        if (max_z != max_x)
          continue;

        ll min_y = t.get_min(x, r);
        debug(min_y);
        if (min_y < max_x)
          continue;
        if (min_y > max_x && r < n - 1 && *(prev(it)) == max_x)
        {
          r++;
          min_y = t.get_min(x, r);
        }
        if (min_y == max_x)
        {
          cout << "YES"
               << "\n";
          cout << x << " " << r - x << " " << n - r;
          good = true;
        }

        // for (ll y = n - x - 1; y > 0; y--)
        // {
        //   max_z = max(max_z, a[x + y]);
        //   //debug(max_z, x, y);
        //   if (max_z > max_x)
        //     break;
        //   if (max_x == max_z)
        //   {
        //     ll min_y = t.get_min(x, x + y);
        //     //debug(t.t);
        //     // ll min_y = 1e10;
        //     // for (ll i = x; i < x + y; i++)
        //     // {
        //     //   min_y = min(min_y, a[i]);
        //     //   //debug(x, y, min_y, max_x, max_z, a[x + y], i);
        //     //   if (min_y < max_x)
        //     //   {
        //     //     break;
        //     //   }
        //     // }
        //     if (min_y == max_x)
        //     {
        //       good = true;
        //       cout << "YES"
        //            << "\n";
        //       cout << x << " " << y << " " << n - x - y;
        //       break;
        //     }
        //     else if (min_y > max_x)
        //     {
        //       break;
        //     }
        //   }

        if (good)
          break;
      }
      if (!good)
        cout << "NO";
      cout << "\n";
    }
    return 0;
  }
};

int main()
{

  auto task = mytask();
  task.solve();

  return 0;
}