/*
* Filename:    cf827E.cpp
* Created:     2017年07月12日 15时57分02秒 星期三
* Author:      ineedAC
* FFT
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int INF=998244353-7;
const int maxn=5e5+7;
const int N=4*maxn;
//           NTT          //   P 1004535809
typedef long long ll;
//const int P = (479 << 21) + 1; // P为符合P=2^k+1的大质数 或者998244353
const int P = 998244353;
const int G = 3; //P的原根
int Wn[25],nWn[25];

inline int qpow(int a, int b)
{
    int re = 1;
    for(; b; b >>= 1, a = (ll) a * a % P)
        if(b & 1)   re = (ll) re * a % P;
    return re;
}
#define INV(x)  (qpow(x, P - 2))
inline void GetWn()
{
    for(int i = 0; i < 25; i++){
        Wn[i] = qpow(G, (P - 1) / (1 << i));
        nWn[i] = INV(Wn[i]);
    }
}

inline void Rader(int F[], int n)
{
    int j = n >> 1;
    for(int i = 1; i < n - 1; i++)
    {
        if(i < j)   swap(F[i], F[j]);
        int k = n >> 1;
        while(j >= k)   j -= k, k >>= 1;
        if(j < k)   j += k;
    }
}
inline void NTT(int F[], int n, int flag)
{
    Rader(F, n);    int id = 0;
    for(int h = 2; h <= n; h <<= 1)
    {
        int wn = flag == 1 ? Wn[++id] : nWn[++id];
        for(int i = 0; i < n; i += h)
        {
            int w = 1;
            for(int j = i; j < i + h / 2; j++)
            {
                int u = F[j];
                int v = (ll) w * F[j + h / 2] % P;
                F[j] = (u + v) % P;
                F[j + h / 2] = (u - v + P) % P;
                w = (ll) w * wn % P;
            }
        }
    }
    if(flag == -1)
    {
        int inv = INV(n);
        for(int i = 0; i < n; i++)  F[i] = (ll) F[i] * inv % P;
    }
}
inline void Convolution(int a[], int n, int b[], int m, int c[], int &len)
{
    static int FA[N], FB[N];
    int i;  len = 1;    GetWn();
    for(; len < n * 2 || len < m * 2; len <<= 1);
    for(i = 0; i < n; i++)  FA[i] = a[i];
    for(; i < len; i++) FA[i] = 0;
    for(i = 0; i < m; i++)  FB[i] = b[i];
    for(; i < len; i++) FB[i] = 0;

    NTT(FA, len, 1);    NTT(FB, len, 1);
    for(i = 0; i < len; i++) FA[i] = (ll) FA[i] * FB[i] % P;
    NTT(FA, len, -1);

    for(i = 0; i < len; i++)    c[i] = FA[i];
}
//           NTT          //
int A[maxn],B[maxn];
int C1[maxn],C2[maxn];

void out(int a[],int b[],int n){
	cout<<"A: ";
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<endl;
	cout<<"B: ";
	for(int i=0;i<n;i++)cout<<b[i]<<" ";
	cout<<endl;
}
int n,m,T;
char s[maxn];
int tmp[maxn];
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
//	freopen("ntt.out","w",stdout);
#endif
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		int len;
		for(int i=0;i<n;i++)
			if(s[i]=='?')B[i]=A[i]=0;
			else B[i]=A[i]=1;
		reverse(B,B+n);

//		out(A,B,n);
//		puts("--------");
//
		Convolution(A,n,B,n,C1,len);

		for(int i=0;i<n;i++)
			if(s[i]=='V')A[i]=-1,B[n-1-i]=-1;
//
//		out(A,B,n);
//		puts("--------");puts("--------");
		Convolution(A,n,B,n,C2,len);
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		for(int i=0;i<2*n;i++){
			if(C2[i]>INF)C2[i]=-1;
		}

//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		int cnt=0;
		char aim='?';
		bool can=true;
		for(int i=0;i<n;i++){
			if(s[i]=='?'||s[i]==aim)continue;
			else{
				if(aim=='?')aim=s[i];
				else can=false;
			}
		}
		if(can)tmp[cnt++]=1;

		for(int i=n+1;i<2*n;i++){
			if(i-n+1<=n/2){
				int len=(i-n+1)*2;
				int nxp=len-1+n;
				if(C1[i]==C2[i]&&C1[nxp]==C2[nxp])tmp[cnt++]=i-n+1;
			}
			else{
				if(C1[i]==C2[i])tmp[cnt++]=i-n+1;
			}
		}
		printf("%d\n",cnt);
		for(int i=0;i<cnt;i++){
			if(i==cnt-1)printf("%d\n",tmp[i]);
			else printf("%d ",tmp[i]);
		}
	}
	return 0;
}


/*
* Filename:    cf827E.cpp
* Created:     2017年07月12日 15时57分02秒 星期三
* Author:      ineedAC
* FFT
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int INF=998244353-7;
const int maxn=5e5+7;
const int maxN=5e5+7;
//           FFT           //
typedef long double ld;
//复数类
const ld PI=acos(-1);
struct Virt
{
	ld r,i;
	Virt(ld r=0.0,ld i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(ld)n;
}
//  求a,b的卷积
//const int N=4*maxn;
const int N=maxN;
inline void Convolution(ld a[], int n, ld b[], int m, ld c[], int &len)
{
	static Virt FA[N], FB[N];
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
ld A[maxn],B[maxn];
ld C1[maxn],C2[maxn];

void out(ld a[],ld b[],int n){
	cout<<"A: ";
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<endl;
	cout<<"B: ";
	for(int i=0;i<n;i++)cout<<b[i]<<" ";
	cout<<endl;
}
int n,m,T;
char s[maxn];
int tmp[maxn];
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	freopen("fft.out","w",stdout);
#endif
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		int len;
		for(int i=0;i<n;i++)
			if(s[i]=='?')B[i]=A[i]=0;
			else B[i]=A[i]=1;
		reverse(B,B+n);
//		out(A,B,n);
//		puts("--------");
		Convolution(A,n,B,n,C1,len);
		for(int i=0;i<n;i++)
			if(s[i]=='V')A[i]=-1,B[n-1-i]=-1;

//		out(A,B,n);
//		puts("--------");puts("--------");
		Convolution(A,n,B,n,C2,len);
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

//		for(int i=0;i<2*n;i++){
//			if(C2[i]>INF)C2[i]=-1;
//		}
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		int cnt=0;
		char aim='?';
		bool can=true;
		for(int i=0;i<n;i++){
			if(s[i]=='?'||s[i]==aim)continue;
			else{
				if(aim=='?')aim=s[i];
				else can=false;
			}
		}
		if(can)tmp[cnt++]=1;

		for(int i=n+1;i<2*n;i++){
			int v1=int(C1[i]+0.5);
			int v2=int(C2[i]+0.5);
			if(i-n+1<=n/2){
				int len=(i-n+1)*2;
				int nxp=len-1+n;
				int va1=int(C1[nxp]+0.5);
				int va2=int(C2[nxp]+0.5);
				if(v1==v2&&va1==va2)tmp[cnt++]=i-n+1;
			}
			else{
				if(v1==v2)tmp[cnt++]=i-n+1;
			}

		}
		printf("%d\n",cnt);
		for(int i=0;i<cnt;i++){
			if(i==cnt-1)printf("%d\n",tmp[i]);
			else printf("%d ",tmp[i]);
		}
	}
	return 0;
}


/*
* Filename:    cf827e.cpp
* Created:     2017年07月19日 21时50分37秒 星期三
* Author:      ineedAC
*
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int INF=1e9+7;

//           FFT           //
const int N= (1 << 20);
//复数类
typedef double ld;
const ld PI=acos(-1);
struct Virt
{
	ld r,i;
	Virt(ld r=0.0,ld i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(ld)n;
}
//  求a,b的卷积

inline void Convolution(ld a[], int n, ld b[], int m, ld c[], int &len)
{
	static Virt FA[N], FB[N];
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
char s[N];
ld a[N],b[N],c[N];
bool can[N];
int n,m,T;
int ans[N];

void print(ld x[],int len){
	return;
	for (int i = 0; i < len; i += 1)
		printf("%.1f\t",x[i]);
	puts("");
}
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
#endif
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		for (int i = 0; i < n; i += 1)
			if(s[i]=='?')a[i]=b[i]=0;
			else a[i]=b[i]=1;
		reverse(a,a+n);
		Convolution(a,n,b,n,c,m);
		print(a,n);print(b,n);print(c,m);

		for (int i = 0; i < n; i += 1)
			if(s[i]=='V')a[i]=b[i]=1;
			else if(s[i]=='K')a[i]=b[i]=-1;
			else a[i]=b[i]=0;

		reverse(a,a+n);
		print(a,n);print(b,n);
		Convolution(a,n,b,n,b,m);
		print(b,m);

		for (int p = n; p >= 1; p += -1){
			int pp=n-1+p;
			can[p]=false;
			if(int(c[pp]+0.5)==(int)(b[pp]+0.5))can[p]=true;
//			if(p>n/2&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
//				can[p]=true;
//			if(p<=n/2&&can[p*2]&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
//				can[p]=true;
		}
//
//		for (int i = 1; i <= n; i += 1)
//			printf("%d  ",can[i]);
//		puts("");
//
		for (int i = n; i >= 1; i += -1){
			for (int j = i+i; j <= n; j += i){
				if(!can[j]){
					can[i]=false;
					break;
				}
			}
		}

		int cnt=0;

		for (int i = 1; i <= n; i += 1)
			if(can[i])ans[cnt++]=i;
//		if(cnt==n-1&&can[1]){
//			printf("%d\n%d ",cnt+1,1);
//		}else

		printf("%d\n",cnt);

		for (int i = 0; i < cnt; i += 1)
			printf("%d%c",ans[i],i==cnt-1?'\n':' ');
	}
	return 0;
}


/*
* Filename:    cf827E.cpp
* Created:     2017年07月12日 15时57分02秒 星期三
* Author:      ineedAC
* FFT
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int INF=998244353-7;
const int maxn=5e5+7;
//           FFT           //
typedef double ld;
//复数类
const ld PI=acos(-1);
struct Virt
{
	ld r,i;
	Virt(ld r=0.0,ld i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(ld)n;
}
//  求a,b的卷积
const int N=2*maxn;
inline void Convolution(ld a[], int n, ld b[], int m, ld c[], int &len)
{
	static Virt FA[N], FB[N];
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
ld A[maxn],B[maxn],C[maxn];

void out(ld a[],ld b[],int n){
	cout<<"A: ";
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<endl;
	cout<<"B: ";
	for(int i=0;i<n;i++)cout<<b[i]<<" ";
	cout<<endl;
}
int n,m,T;
char s[maxn];
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	freopen("fft.out","w",stdout);
#endif
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		int len;
		for(int i=0;i<n;i++)
			if(s[i]=='?')B[i]=A[i]=0;
			else B[i]=A[i]=1;
		reverse(B,B+n);
//		out(A,B,n);
//		puts("--------");
		Convolution(A,n,B,n,C,len);
		for(int i=0;i<n;i++)
			if(s[i]=='V')A[i]=-1,B[n-1-i]=-1;

//		out(A,B,n);
//		puts("--------");puts("--------");
		Convolution(A,n,B,n,A,len);
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

//		for(int i=0;i<2*n;i++){
//			if(C2[i]>INF)C2[i]=-1;
//		}
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		int cnt=0;
		char aim='?';
		bool can=true;
		for(int i=0;i<n;i++){
			if(s[i]=='?'||s[i]==aim)continue;
			else{
				if(aim=='?')aim=s[i];
				else can=false;
			}
		}
		if(can)s[cnt++]=1;

		for(int i=n+1;i<2*n;i++){
			int v1=int(A[i]+0.5);
			int v2=int(C[i]+0.5);
			if(i-n+1<=n/2){
				int len=(i-n+1)*2;
				int nxp=len-1+n;
				int va1=int(A[nxp]+0.5);
				int va2=int(C[nxp]+0.5);
				if(v1==v2&&va1==va2)s[cnt++]=i-n+1;
			}
			else{
				if(v1==v2)s[cnt++]=i-n+1;
			}

		}
		printf("%d\n",cnt);
		for(int i=0;i<cnt;i++){
			if(i==cnt-1)printf("%d\n",s[i]);
			else printf("%d ",s[i]);
		}
	}
	return 0;
}


/*
* Filename:    cf827e.cpp
* Created:     2017年07月19日 21时50分37秒 星期三
* Author:      ineedAC
*
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int INF=1e9+7;

//           FFT           //
const int N= (1 << 20);
//复数类
const double PI=acos(-1);
struct Virt
{
	double r,i;
	Virt(double r=0.0,double i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(double)n;
}
//  求a,b的卷积
Virt FA[N], FB[N];
inline void Convolution(double a[], int n, double b[], int m, double c[], int &len)
{
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
char s[N];
double a[N],b[N],c[N];
bool can[N];
int n,m,T;
int ans[N];

void print(double x[],int len){
	return;
	for (int i = 0; i < len; i += 1)
		printf("%.1f\t",x[i]);
	puts("");
}
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
#endif
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		for (int i = 0; i < n; i += 1)
			if(s[i]=='?')a[i]=b[i]=0;
			else a[i]=b[i]=1;
		reverse(a,a+n);
		Convolution(a,n,b,n,c,m);
		print(a,n);print(b,n);print(c,m);

		for (int i = 0; i < n; i += 1)
			if(s[i]=='V')a[i]=b[i]=1;
			else if(s[i]=='K')a[i]=b[i]=-1;
			else a[i]=b[i]=0;

		reverse(a,a+n);
		print(a,n);print(b,n);
		Convolution(a,n,b,n,b,m);
		print(b,m);

		for (int p = n; p >= 1; p += -1){
			can[p]=false;
			int pp=n-1+p;
			if(p>n/2&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
				can[p]=true;
			if(p<=n/2&&can[p*2]&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
				can[p]=true;
		}
		int cnt=0;
		for (int i = 2; i <= n; i += 1)
			if(can[i])ans[cnt++]=i;
		if(cnt==n-1&&can[1]){
			printf("%d\n%d ",cnt+1,1);
		}else printf("%d\n",cnt);

		for (int i = 0; i < cnt; i += 1)
			printf("%d%c",ans[i],i==cnt-1?'\n':' ');
	}
	return 0;
}


/*
* Filename:    cf827e.cpp
* Created:     2017年07月19日 21时50分37秒 星期三
* Author:      ineedAC
*
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int INF=1e9+7;

//           FFT           //
const int N= (1 << 18);
//复数类
const double PI=acos(-1);
struct Virt
{
	double r,i;
	Virt(double r=0.0,double i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(double)n;
}
//  求a,b的卷积
inline void Convolution(double a[], int n, double b[], int m, double c[], int &len)
{
	static Virt FA[N], FB[N];
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
char s[N];
double a[N],b[N],c[N];
bool can[N];
int n,m,T;
int ans[N];

void print(double x[],int len){
	return;
	for (int i = 0; i < len; i += 1)
		printf("%.1f\t",x[i]);
	puts("");
}
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
#endif
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		for (int i = 0; i < n; i += 1)
			if(s[i]=='?')a[i]=b[i]=0;
			else a[i]=b[i]=1;
		reverse(a,a+n);
		Convolution(a,n,b,n,c,m);
		print(a,n);print(b,n);print(c,m);

		for (int i = 0; i < n; i += 1)
			if(s[i]=='V')a[i]=b[i]=1;
			else if(s[i]=='K')a[i]=b[i]=-1;
			else a[i]=b[i]=0;

		reverse(a,a+n);
		print(a,n);print(b,n);
		Convolution(a,n,b,n,b,m);
		print(b,m);

		for (int p = n; p >= 1; p += -1){
			can[p]=false;
			int pp=n-1+p;
			if(p>n/2&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
				can[p]=true;
			if(p<=n/2&&can[p*2]&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
				can[p]=true;
		}
		int cnt=0;
		for (int i = 2; i <= n; i += 1)
			if(can[i])ans[cnt++]=i;
		if(cnt==n-1&&can[1]){
			printf("%d\n%d ",cnt+1,1);
		}else printf("%d\n",cnt);

		for (int i = 0; i < cnt; i += 1)
			printf("%d%c",ans[i],i==cnt-1?'\n':' ');
	}
	return 0;
}


/*
* Filename:    cf827e.cpp
* Created:     2017年07月19日 21时50分37秒 星期三
* Author:      ineedAC
*
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int INF=1e9+7;

//           FFT           //
const int N= (1 << 20);
typedef double ld;
//复数类
const ld PI=acos(-1);
struct Virt
{
	ld r,i;
	Virt(ld r=0.0,ld i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(ld)n;
}
//  求a,b的卷积
inline void Convolution(ld a[], int n, ld b[], int m, ld c[], int &len)
{
	static Virt FA[N], FB[N];
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
char s[500000+7];
ld a[N],b[N],c[N];
bool can[500000+7];
vector<int> ans;
int n,m,T;
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
#endif
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		for (int i = 0; i < n; i += 1)
			if(s[i]=='?')a[i]=b[i]=0;
			else a[i]=b[i]=1;
		reverse(a,a+n);
		Convolution(a,n,b,n,c,m);
		for (int i = 0; i < n; i += 1)
			if(s[i]=='V')b[i]=1;
			else if(s[i]=='K')b[i]=-1;
			else b[i]=0;
		Convolution(a,n,b,n,b,m);
		for (int p = n; p >= 1; p += -1){
			can[p]=false;
			int pp=n-1+p;
			if(p>n/2&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
				can[p]=true;
			if(p<=n/2&&can[p*2]&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
				can[p]=true;
		}
		ans.clear();
		for (int i = 1; i <= n; i += 1)
			if(can[i])ans.pb(i);
		printf("%d\n",SZ(ans));
		for (int i = 0; i < SZ(ans); i += 1)
			printf("%d%c",ans[i],i==SZ(ans)-1?'\n':' ');
	}
	return 0;
}


/*
* Filename:    cf827e.cpp
* Created:     2017年07月19日 21时50分37秒 星期三
* Author:      ineedAC
*
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int INF=1e9+7;

//           FFT           //
const int N= (1 << 20);
typedef double ld;
//复数类
const ld PI=acos(-1);
struct Virt
{
	ld r,i;
	Virt(ld r=0.0,ld i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(ld)n;
}
//  求a,b的卷积
inline void Convolution(ld a[], int n, ld b[], int m, ld c[], int &len)
{
	static Virt FA[N], FB[N];
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
char s[500000+7];
ld a[N],b[N],c[N];
bool can[500000+7];
vector<int> ans;
int n,m,T;
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
#endif
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		for (int i = 0; i < n; i += 1)
			if(s[i]=='?')a[i]=b[i]=0;
			else a[i]=b[i]=1;
		reverse(a,a+n);
		Convolution(a,n,b,n,c,m);
		for (int i = 0; i < n; i += 1)
			if(s[i]=='V')b[i]=1;
			else if(s[i]=='K')b[i]=-1;
			else b[i]=0;
		Convolution(a,n,b,n,b,m);
		for (int p = n; p >= 1; p += -1){
			can[p]=false;
			int pp=n-1+p;
			if(p>n/2&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
				can[p]=true;
			if(p<=n/2&&can[p*2]&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
				can[p]=true;
		}
		ans.clear();
		for (int i = 1; i <= n; i += 1)
			if(can[i])ans.pb(i);
		printf("%d\n",SZ(ans));
		for (int i = 0; i < SZ(ans); i += 1)
			printf("%d%c",ans[i],i==SZ(ans)-1?'\n':' ');
	}
	return 0;
}


/*
* Filename:    cf827E.cpp
* Created:     2017年07月12日 15时57分02秒 星期三
* Author:      ineedAC
* FFT
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int INF=998244353-7;
const int maxn=5e5+7;
//           FFld           //
typedef double ld;
//复数类
const int MAXN = 1 << 20;
struct cplex {
    ld r, i;
    cplex() : r(0), i(0) {}
    cplex(ld n) : r(n), i(0) {}
    cplex(ld r, ld i) : r(r), i(i) {}
    ld real() {return r;}
    cplex operator + (cplex b) {return cplex (r + b.r, i + b.i);}
    cplex operator += (cplex b) {r += b.r, i += b.i; return *this;}
    cplex operator - (cplex b) {return cplex(r - b.r, i - b.i);}
    cplex operator * (cplex b) {return cplex(r * b.r - i * b.i, r * b.i + i * b.r);}
    cplex operator *= (cplex b) {ld r2 = r * b.r - i * b.i, i2 = r * b.i + i * b.r; r = r2, i = i2; return *this;}
    cplex operator /= (ld n) {r /= n, i /= n; return *this;}
};
void fft(cplex a[], int n, int invert) {
    static ld PI = 2 * acos((ld) 0);
    for (int i = 1, j = 0; i < n; i++) {
        for (int s = n; j ^= s >>= 1, ~j & s;);
        if (i < j) swap(a[i], a[j]);
    }
    for (int m = 1; m < n; m <<= 1) {
        ld p = PI / m * (invert ? -1 : 1);
        cplex w = cplex(cos(p), sin(p));
        for (int i = 0; i < n; i += m << 1) {
            cplex unit = 1;
            for (int j = 0; j < m; j++) {
                cplex& x = a[i + j + m], &y = a[i + j], t = unit * x;
                x = y - t;
                y = y + t;
                unit *= w;
            }
        }
    }
    if (invert) for (int i = 0; i < n; i++) a[i] /= n;
}
void multiply(int a[], int b[], int c[], int na, int nb) {
    static cplex fa[MAXN << 1], fb[MAXN << 1];
    int n = 1; while (n < na + nb - 1) n <<= 1;
    for (int i = 0; i < n; i++) fa[i] = fb[i] = cplex(0);
    for (int i = 0; i < na; i++) fa[i] = cplex(a[i]);
    for (int i = 0; i < nb; i++) fb[i] = cplex(b[i]);
    fft(fa, n, 0); fft(fb, n, 0);
    for (int i = 0; i < n; i++) fa[i] *= fb[i];
    fft(fa, n, 1);
    for (int i = 0; i < n; i++) c[i] = (long long) (fa[i].real() + 0.5);
}
//           FFT           //
int A[maxn],B[maxn],C[maxn];

void out(ld a[],ld b[],int n){
	cout<<"A: ";
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<endl;
	cout<<"B: ";
	for(int i=0;i<n;i++)cout<<b[i]<<" ";
	cout<<endl;
}
int n,m,T;
char s[maxn];
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	freopen("fft.out","w",stdout);
#endif
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		for(int i=0;i<n;i++)
			if(s[i]=='?')B[i]=A[i]=0;
			else B[i]=A[i]=1;
		reverse(B,B+n);
//		out(A,B,n);
//		puts("--------");
		multiply(A,B,C,n,n);
		for(int i=0;i<n;i++)
			if(s[i]=='V')A[i]=-1,B[n-1-i]=-1;

//		out(A,B,n);
//		puts("--------");puts("--------");
		multiply(A,B,A,n,n);
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

//		for(int i=0;i<2*n;i++){
//			if(C2[i]>INF)C2[i]=-1;
//		}
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		int cnt=0;
		char aim='?';
		bool can=true;
		for(int i=0;i<n;i++){
			if(s[i]=='?'||s[i]==aim)continue;
			else{
				if(aim=='?')aim=s[i];
				else can=false;
			}
		}
		if(can)s[cnt++]=1;

		for(int i=n+1;i<2*n;i++){
			int v1=int(A[i]+0.5);
			int v2=int(C[i]+0.5);
			if(i-n+1<=n/2){
				int len=(i-n+1)*2;
				int nxp=len-1+n;
				int va1=int(A[nxp]+0.5);
				int va2=int(C[nxp]+0.5);
				if(v1==v2&&va1==va2)s[cnt++]=i-n+1;
			}
			else{
				if(v1==v2)s[cnt++]=i-n+1;
			}

		}
		printf("%d\n",cnt);
		for(int i=0;i<cnt;i++){
			if(i==cnt-1)printf("%d\n",s[i]);
			else printf("%d ",s[i]);
		}
	}
	return 0;
}


/*
* Filename:    cf827E.cpp
* Created:     2017年07月12日 15时57分02秒 星期三
* Author:      ineedAC
* FFT
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int INF=998244353-7;
const int maxn=5e5+7;
const int N=4*maxn;
//           NTT          //   P 1004535809
typedef long long ll;
//const int P = (479 << 21) + 1; // P为符合P=2^k+1的大质数 或者998244353
const int P = 998244353;
const int G = 3; //P的原根
int Wn[25],nWn[25];

inline int qpow(int a, int b)
{
    int re = 1;
    for(; b; b >>= 1, a = (ll) a * a % P)
        if(b & 1)   re = (ll) re * a % P;
    return re;
}
#define INV(x)  (qpow(x, P - 2))
inline void GetWn()
{
    for(int i = 0; i < 25; i++){
        Wn[i] = qpow(G, (P - 1) / (1 << i));
        nWn[i] = INV(Wn[i]);
    }
}

inline void Rader(int F[], int n)
{
    int j = n >> 1;
    for(int i = 1; i < n - 1; i++)
    {
        if(i < j)   swap(F[i], F[j]);
        int k = n >> 1;
        while(j >= k)   j -= k, k >>= 1;
        if(j < k)   j += k;
    }
}
inline void NTT(int F[], int n, int flag)
{
    Rader(F, n);    int id = 0;
    for(int h = 2; h <= n; h <<= 1)
    {
        int wn = flag == 1 ? Wn[++id] : nWn[++id];
        for(int i = 0; i < n; i += h)
        {
            int w = 1;
            for(int j = i; j < i + h / 2; j++)
            {
                int u = F[j];
                int v = (ll) w * F[j + h / 2] % P;
                F[j] = (u + v) % P;
                F[j + h / 2] = (u - v + P) % P;
                w = (ll) w * wn % P;
            }
        }
    }
    if(flag == -1)
    {
        int inv = INV(n);
        for(int i = 0; i < n; i++)  F[i] = (ll) F[i] * inv % P;
    }
}
inline void Convolution(int a[], int n, int b[], int m, int c[], int &len)
{
    static int FA[N], FB[N];
    int i;  len = 1;    GetWn();
    for(; len < n * 2 || len < m * 2; len <<= 1);
    for(i = 0; i < n; i++)  FA[i] = a[i];
    for(; i < len; i++) FA[i] = 0;
    for(i = 0; i < m; i++)  FB[i] = b[i];
    for(; i < len; i++) FB[i] = 0;

    NTT(FA, len, 1);    NTT(FB, len, 1);
    for(i = 0; i < len; i++) FA[i] = (ll) FA[i] * FB[i] % P;
    NTT(FA, len, -1);

    for(i = 0; i < len; i++)    c[i] = FA[i];
}
//           NTT          //
int A[maxn],B[maxn];
int C1[maxn],C2[maxn];

void out(ll a[],ll b[],int n){
	cout<<"A: ";
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<endl;
	cout<<"B: ";
	for(int i=0;i<n;i++)cout<<b[i]<<" ";
	cout<<endl;
}
int n,m,T;
char s[maxn];
int tmp[maxn];
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
#endif
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		int len;
		for(int i=0;i<n;i++)
			if(s[i]=='?')B[i]=A[i]=0;
			else B[i]=A[i]=1;
		reverse(B,B+n);
//		out(A,B,n);
//		puts("--------");
		Convolution(A,n,B,n,C1,len);
		for(int i=0;i<n;i++)
			if(s[i]=='V')A[i]=-1,B[n-1-i]=-1;

//		out(A,B,n);
//		puts("--------");puts("--------");
		Convolution(A,n,B,n,C2,len);
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		for(int i=0;i<2*n;i++){
			if(C2[i]>INF)C2[i]=-1;
		}
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		int cnt=0;
		for(int i=n;i<2*n;i++){
			if(i-n+1<=n/2){
				int len=(i-n+1)*2;
				int nxp=len-1+n;
				if(C1[i]==C2[i]&&C1[nxp]==C2[nxp])tmp[cnt++]=i-n+1;
			}
			else{
				if(C1[i]==C2[i])tmp[cnt++]=i-n+1;
			}

		}
		printf("%d\n",cnt);
		for(int i=0;i<cnt;i++){
			if(i==cnt-1)printf("%d\n",tmp[i]);
			else printf("%d ",tmp[i]);
		}
	}
	return 0;
}


/*
* Filename:    cf827E.cpp
* Created:     2017年07月12日 15时57分02秒 星期三
* Author:      ineedAC
* FFT
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int INF=998244353-7;
const int maxn=5e5+7;
const int N=4*maxn;
//           NTT          //   P 1004535809
typedef long long ll;
//const int P = (479 << 21) + 1; // P为符合P=2^k+1的大质数 或者998244353
const int P = 998244353;
const int G = 3; //P的原根
int Wn[25],nWn[25];

inline int qpow(int a, int b)
{
    int re = 1;
    for(; b; b >>= 1, a = (ll) a * a % P)
        if(b & 1)   re = (ll) re * a % P;
    return re;
}
#define INV(x)  (qpow(x, P - 2))
inline void GetWn()
{
    for(int i = 0; i < 25; i++){
        Wn[i] = qpow(G, (P - 1) / (1 << i));
        nWn[i] = INV(Wn[i]);
    }
}

inline void Rader(int F[], int n)
{
    int j = n >> 1;
    for(int i = 1; i < n - 1; i++)
    {
        if(i < j)   swap(F[i], F[j]);
        int k = n >> 1;
        while(j >= k)   j -= k, k >>= 1;
        if(j < k)   j += k;
    }
}
inline void NTT(int F[], int n, int flag)
{
    Rader(F, n);    int id = 0;
    for(int h = 2; h <= n; h <<= 1)
    {
        int wn = flag == 1 ? Wn[++id] : nWn[++id];
        for(int i = 0; i < n; i += h)
        {
            int w = 1;
            for(int j = i; j < i + h / 2; j++)
            {
                int u = F[j];
                int v = (ll) w * F[j + h / 2] % P;
                F[j] = (u + v) % P;
                F[j + h / 2] = (u - v + P) % P;
                w = (ll) w * wn % P;
            }
        }
    }
    if(flag == -1)
    {
        int inv = INV(n);
        for(int i = 0; i < n; i++)  F[i] = (ll) F[i] * inv % P;
    }
}
inline void Convolution(int a[], int n, int b[], int m, int c[], int &len)
{
    static int FA[N], FB[N];
    int i;  len = 1;    GetWn();
    for(; len < n * 2 || len < m * 2; len <<= 1);
    for(i = 0; i < n; i++)  FA[i] = a[i];
    for(; i < len; i++) FA[i] = 0;
    for(i = 0; i < m; i++)  FB[i] = b[i];
    for(; i < len; i++) FB[i] = 0;

    NTT(FA, len, 1);    NTT(FB, len, 1);
    for(i = 0; i < len; i++) FA[i] = (ll) FA[i] * FB[i] % P;
    NTT(FA, len, -1);

    for(i = 0; i < len; i++)    c[i] = FA[i];
}
//           NTT          //
int A[maxn],B[maxn];
int C1[maxn],C2[maxn];

void out(int a[],int b[],int n){
	cout<<"A: ";
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<endl;
	cout<<"B: ";
	for(int i=0;i<n;i++)cout<<b[i]<<" ";
	cout<<endl;
}
int n,m,T;
char s[maxn];
int tmp[maxn];
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
//	freopen("ntt.out","w",stdout);
#endif
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		int len;
		for(int i=0;i<n;i++)
			if(s[i]=='?')B[i]=A[i]=0;
			else B[i]=A[i]=1;
		reverse(B,B+n);
//		out(A,B,n);
//		puts("--------");
		Convolution(A,n,B,n,C1,len);
		for(int i=0;i<n;i++)
			if(s[i]=='V')A[i]=-1,B[n-1-i]=-1;

//		out(A,B,n);
//		puts("--------");puts("--------");
		Convolution(A,n,B,n,C2,len);
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		for(int i=0;i<2*n;i++){
			if(C2[i]>INF)C2[i]=-1;
		}

//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		int cnt=0;
		for(int i=n+1;i<2*n;i++){
			if(i-n<=n/2){
				int len=(i-n)*2;
				int nxp=len+n;
				if(C1[i]==C2[i]&&C1[nxp]==C2[nxp])tmp[cnt++]=i-n;
			}
			else{
				if(C1[i]==C2[i])tmp[cnt++]=i-n;
			}

		}
		tmp[cnt++]=n;
		printf("%d\n",cnt);
		for(int i=0;i<cnt;i++){
			if(i==cnt-1)printf("%d\n",tmp[i]);
			else printf("%d ",tmp[i]);
		}
	}
	return 0;
}


/*
* Filename:    cf827e.cpp
* Created:     2017年07月19日 21时50分37秒 星期三
* Author:      ineedAC
*
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int INF=1e9+7;

//           FFT           //
const int N= (1 << 20);
//复数类
const double PI=acos(-1);
struct Virt
{
	double r,i;
	Virt(double r=0.0,double i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(double)n;
}
//  求a,b的卷积
Virt FA[N], FB[N];
inline void Convolution(double a[], int n, double b[], int m, double c[], int &len)
{
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
char s[N];
double a[N],b[N],c[N];
bool can[N];
int n,m,T;
int ans[N];

void print(double x[],int len){
	return;
	for (int i = 0; i < len; i += 1)
		printf("%.1f\t",x[i]);
	puts("");
}
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
#endif
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		for (int i = 0; i < n; i += 1)
			if(s[i]=='?')a[i]=b[i]=0;
			else a[i]=b[i]=1;
		reverse(a,a+n);
		Convolution(a,n,b,n,c,m);
		print(a,n);print(b,n);print(c,m);

		for (int i = 0; i < n; i += 1)
			if(s[i]=='V')a[i]=b[i]=1;
			else if(s[i]=='K')a[i]=b[i]=-1;
			else a[i]=b[i]=0;

		reverse(a,a+n);
		print(a,n);print(b,n);
		Convolution(a,n,b,n,b,m);
		print(b,m);

		for (int p = n; p >= 1; p += -1){
			int pp=n-1+p;
			can[p]=false;
			if(int(c[pp]+0.5)==(int)(b[pp]+0.5))can[p]=true;
//			if(p>n/2&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
//				can[p]=true;
//			if(p<=n/2&&can[p*2]&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
//				can[p]=true;
		}
//
//		for (int i = 1; i <= n; i += 1)
//			printf("%d  ",can[i]);
//		puts("");
//
		for (int i = n; i >= 1; i += -1){
			for (int j = i+i; j <= n; j += i){
				if(!can[j]){
					can[i]=false;
					break;
				}
			}
		}

		int cnt=0;

		for (int i = 1; i <= n; i += 1)
			if(can[i])ans[cnt++]=i;
//		if(cnt==n-1&&can[1]){
//			printf("%d\n%d ",cnt+1,1);
//		}else

		printf("%d\n",cnt);

		for (int i = 0; i < cnt; i += 1)
			printf("%d%c",ans[i],i==cnt-1?'\n':' ');
	}
	return 0;
}


/*
* Filename:    cf827E.cpp
* Created:     2017年07月12日 15时57分02秒 星期三
* Author:      ineedAC
* FFT
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int INF=998244353-7;
const int maxn=5e5+7;
//           FFT           //
typedef double ld;
//复数类
const ld PI=acos(-1);
struct Virt
{
	ld r,i;
	Virt(ld r=0.0,ld i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(ld)n;
}
//  求a,b的卷积
const int N=2*maxn;
inline void Convolution(ld a[], int n, ld b[], int m, ld c[], int &len)
{
	static Virt FA[N], FB[N];
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
ld A[maxn],B[maxn];
ld C1[maxn],C2[maxn];

void out(ld a[],ld b[],int n){
	cout<<"A: ";
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<endl;
	cout<<"B: ";
	for(int i=0;i<n;i++)cout<<b[i]<<" ";
	cout<<endl;
}
int n,m,T;
char s[maxn];
int tmp[maxn];
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	freopen("fft.out","w",stdout);
#endif
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		int len;
		for(int i=0;i<n;i++)
			if(s[i]=='?')B[i]=A[i]=0;
			else B[i]=A[i]=1;
		reverse(B,B+n);
//		out(A,B,n);
//		puts("--------");
		Convolution(A,n,B,n,C1,len);
		for(int i=0;i<n;i++)
			if(s[i]=='V')A[i]=-1,B[n-1-i]=-1;

//		out(A,B,n);
//		puts("--------");puts("--------");
		Convolution(A,n,B,n,C2,len);
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

//		for(int i=0;i<2*n;i++){
//			if(C2[i]>INF)C2[i]=-1;
//		}
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		int cnt=0;
		char aim='?';
		bool can=true;
		for(int i=0;i<n;i++){
			if(s[i]=='?'||s[i]==aim)continue;
			else{
				if(aim=='?')aim=s[i];
				else can=false;
			}
		}
		if(can)tmp[cnt++]=1;

		for(int i=n+1;i<2*n;i++){
			int v1=int(C1[i]+0.5);
			int v2=int(C2[i]+0.5);
			if(i-n+1<=n/2){
				int len=(i-n+1)*2;
				int nxp=len-1+n;
				int va1=int(C1[nxp]+0.5);
				int va2=int(C2[nxp]+0.5);
				if(v1==v2&&va1==va2)tmp[cnt++]=i-n+1;
			}
			else{
				if(v1==v2)tmp[cnt++]=i-n+1;
			}

		}
		printf("%d\n",cnt);
		for(int i=0;i<cnt;i++){
			if(i==cnt-1)printf("%d\n",tmp[i]);
			else printf("%d ",tmp[i]);
		}
	}
	return 0;
}


/*
* Filename:    cf827e.cpp
* Created:     2017年07月19日 21时50分37秒 星期三
* Author:      ineedAC
*
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int INF=1e9+7;

//           FFT           //
const int N= (1 << 18);
//复数类
const double PI=acos(-1);
struct Virt
{
	double r,i;
	Virt(double r=0.0,double i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(double)n;
}
//  求a,b的卷积
inline void Convolution(double a[], int n, double b[], int m, double c[], int &len)
{
	static Virt FA[N], FB[N];
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
char s[N];
double a[N],b[N],c[N];
bool can[N];
int n,m,T;
int ans[N];

void print(double x[],int len){
	return;
	for (int i = 0; i < len; i += 1)
		printf("%.1f\t",x[i]);
	puts("");
}
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
#endif
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		for (int i = 0; i < n; i += 1)
			if(s[i]=='?')a[i]=b[i]=0;
			else a[i]=b[i]=1;
		reverse(a,a+n);
		Convolution(a,n,b,n,c,m);
		print(a,n);print(b,n);print(c,m);

		for (int i = 0; i < n; i += 1)
			if(s[i]=='V')a[i]=b[i]=1;
			else if(s[i]=='K')a[i]=b[i]=-1;
			else a[i]=b[i]=0;

		reverse(a,a+n);
		print(a,n);print(b,n);
		Convolution(a,n,b,n,b,m);
		print(b,m);

		for (int p = n; p >= 1; p += -1){
			can[p]=false;
			int pp=n-1+p;
			if(p>n/2&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
				can[p]=true;
			if(p<=n/2&&can[p*2]&&int(c[pp]+0.5)==(int)(b[pp]+0.5))
				can[p]=true;
		}
		int cnt=0;
		for (int i = 1; i <= n; i += 1)
			if(can[i])ans[cnt++]=i;
		printf("%d\n",cnt);
		for (int i = 0; i < cnt; i += 1)
			printf("%d%c",ans[i],i==cnt-1?'\n':' ');
	}
	return 0;
}


/*
* Filename:    cf827E.cpp
* Created:     2017年07月12日 15时57分02秒 星期三
* Author:      ineedAC
* FFT
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int INF=998244353-7;
const int maxn=5e5+7;
const int maxN=5e5+7;
//           FFT           //
typedef long double ld;
//复数类
const ld PI=acos(-1);
struct Virt
{
	ld r,i;
	Virt(ld r=0.0,ld i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(ld)n;
}
//  求a,b的卷积
//const int N=4*maxn;
const int N=maxN;
inline void Convolution(ld a[], int n, ld b[], int m, ld c[], int &len)
{
	static Virt FA[N], FB[N];
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
ld A[maxn],B[maxn];
ld C1[maxn],C2[maxn];

void out(ld a[],ld b[],int n){
	cout<<"A: ";
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<endl;
	cout<<"B: ";
	for(int i=0;i<n;i++)cout<<b[i]<<" ";
	cout<<endl;
}
int n,m,T;
char s[maxn];
int tmp[maxn];
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
#endif
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		int len;
		for(int i=0;i<n;i++)
			if(s[i]=='?')B[i]=A[i]=0;
			else B[i]=A[i]=1;
		reverse(B,B+n);
//		out(A,B,n);
//		puts("--------");
		Convolution(A,n,B,n,C1,len);
		for(int i=0;i<n;i++)
			if(s[i]=='V')A[i]=-1,B[n-1-i]=-1;

//		out(A,B,n);
//		puts("--------");puts("--------");
		Convolution(A,n,B,n,C2,len);
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

//		for(int i=0;i<2*n;i++){
//			if(C2[i]>INF)C2[i]=-1;
//		}
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		int cnt=0;
		for(int i=n;i<2*n;i++){
			int v1=int(C1[i]+0.5);
			int v2=int(C2[i]+0.5);
			if(i-n+1<=n/2){
				int len=(i-n+1)*2;
				int nxp=len-1+n;
				int va1=int(C1[nxp]+0.5);
				int va2=int(C2[nxp]+0.5);
				if(v1==v2&&va1==va2)tmp[cnt++]=i-n+1;
			}
			else{
				if(v1==v2)tmp[cnt++]=i-n+1;
			}

		}
		printf("%d\n",cnt);
		for(int i=0;i<cnt;i++){
			if(i==cnt-1)printf("%d\n",tmp[i]);
			else printf("%d ",tmp[i]);
		}
	}
	return 0;
}


/*
* Filename:    cf827E.cpp
* Created:     2017年07月12日 15时57分02秒 星期三
* Author:      ineedAC
* FFT
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define clr(a,b) (memset(a,b,sizeof(a)))
#define y0 y3487465
#define y1 y8687969
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int INF=998244353-7;
const int maxn=5e5+7;
//           FFT           //
typedef long double ld;
//复数类
const ld PI=acos(-1);
struct Virt
{
	ld r,i;
	Virt(ld r=0.0,ld i=0.0):r(r),i(i){}
	friend Virt operator - (const Virt &a, const Virt &b) { return Virt(a.r - b.r, a.i - b.i); }
	friend Virt operator + (const Virt &a, const Virt &b) { return Virt(a.r + b.r, a.i + b.i); }
	friend Virt operator * (const Virt &a, const Virt &b) { return Virt(a.r * b.r - a.i * b.i, a.r * b.i + a.i * b.r); }
};
inline void Rader(Virt F[], int n){
	int j=n>>1;
	for (int i = 1; i < n-1; i += 1){
		if(i<j)swap(F[i],F[j]);
		int k=n>>1;
		while(j>=k)j-=k,k>>=1;
		if(j<k)j+=k;
	}
}
inline void FFT(Virt F[],int n,int flag){
	Rader(F,n);
	for (int h = 2; h <= n; h <<= 1){
		Virt wn(cos(flag * 2 * PI / h), sin(flag * 2 * PI / h));
		for (int i = 0; i < n; i += h){
			Virt w(1,0);
			for (int j = i; j < i+h/2; j += 1){
				Virt u = F[j];
				Virt v = w * F[j + h / 2];
				F[j] = u + v;
				F[j + h / 2 ] = u - v;
				w = w* wn;
			}
		}
	}
	if(flag == -1)  for(int i = 0; i < n; i++)  F[i].r /=(ld)n;
}
//  求a,b的卷积
const int N=3*maxn;
inline void Convolution(ld a[], int n, ld b[], int m, ld c[], int &len)
{
	static Virt FA[N], FB[N];
	int i;  len = 1;
	while(len < 2 * n || len < 2 * m)   len <<= 1;
	for(i = 0; i < n; i++)  FA[i] = Virt(a[i]);
	for(; i < len; i++) FA[i] = Virt();
	for(i = 0; i < m; i++)  FB[i] = Virt(b[i]);
	for(; i < len; i++) FB[i] = Virt();

	FFT(FA, len, 1);    FFT(FB, len, 1);
	for(i = 0; i < len; i++)    FA[i] = FA[i] * FB[i];
	FFT(FA, len, -1);

	for(i = 0; i < len; i++)    c[i] = FA[i].r;
}
//           FFT           //
ld A[maxn],B[maxn];
ld C1[maxn],C2[maxn];

void out(ld a[],ld b[],int n){
	cout<<"A: ";
	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<endl;
	cout<<"B: ";
	for(int i=0;i<n;i++)cout<<b[i]<<" ";
	cout<<endl;
}
int n,m,T;
char s[maxn];
int tmp[maxn];
int main()
{
#ifdef AC
	freopen("data.in","r",stdin);
	freopen("fft.out","w",stdout);
#endif
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%d%s",&n,s);
		int len;
		for(int i=0;i<n;i++)
			if(s[i]=='?')B[i]=A[i]=0;
			else B[i]=A[i]=1;
		reverse(B,B+n);
//		out(A,B,n);
//		puts("--------");
		Convolution(A,n,B,n,C1,len);
		for(int i=0;i<n;i++)
			if(s[i]=='V')A[i]=-1,B[n-1-i]=-1;

//		out(A,B,n);
//		puts("--------");puts("--------");
		Convolution(A,n,B,n,C2,len);
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

//		for(int i=0;i<2*n;i++){
//			if(C2[i]>INF)C2[i]=-1;
//		}
//		out(C1,C2,2*n);
//		puts("--------");puts("--------");

		int cnt=0;
		char aim='?';
		bool can=true;
		for(int i=0;i<n;i++){
			if(s[i]=='?'||s[i]==aim)continue;
			else{
				if(aim=='?')aim=s[i];
				else can=false;
			}
		}
		if(can)tmp[cnt++]=1;

		for(int i=n+1;i<2*n;i++){
			int v1=int(C1[i]+0.5);
			int v2=int(C2[i]+0.5);
			if(i-n+1<=n/2){
				int len=(i-n+1)*2;
				int nxp=len-1+n;
				int va1=int(C1[nxp]+0.5);
				int va2=int(C2[nxp]+0.5);
				if(v1==v2&&va1==va2)tmp[cnt++]=i-n+1;
			}
			else{
				if(v1==v2)tmp[cnt++]=i-n+1;
			}

		}
		printf("%d\n",cnt);
		for(int i=0;i<cnt;i++){
			if(i==cnt-1)printf("%d\n",tmp[i]);
			else printf("%d ",tmp[i]);
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define mod 998244353
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> P;
const LL INF = 0x3f3f3f3f;
const int N = 2e6 + 100; //n = maxn << 2;
const int g[2] = {3, (mod + 1) / 3};
const LL inv2 = mod + 1 >> 1;

inline int add(int a, int b){
    int x = a + b;   return x >= mod ? x - mod : x;
}
inline int pp(int x, int y){
    int ret = 1;
    while(y){
        if(y & 1)   ret = ret * 1ll * x % mod;
        x = x * 1ll * x % mod, y >>= 1;
    }
    return ret;
}

int rev[N];
void init(int p){
    for(int i = 0; i < (1 << p); ++i)    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (p - 1));
}
void ntt(int *a, int n, int op){
    for(int i = 0; i < n; ++i)  if(i < rev[i])  swap(a[i], a[rev[i]]);
    int wn , w;
    for(int i = 1; i < n; i <<= 1){
        wn = pp(g[op], (mod - 1) / (i << 1));
        for(int j = 0; j < n; j += (i << 1)){
            w = 1;
            for(int k = j; k < j + i; ++k){
                LL u = a[k], v = w * 1ll * a[k + i] % mod;
                a[k] = add(u, v), a[k + i] = add(u - v, mod);
                w = w * 1ll * wn % mod;
            }
        }
    }
    if(op)  for(int i = 0, inv = pp(n, mod - 2); i < n; ++i)  a[i] = a[i] * 1ll * inv % mod;
}
int a[N], b[N], ans[N];
char s[N];
void solve(){
    int n, p;
    scanf("%d%s", &n, s);
    p = 0; while((1 << p) < n) ++p; ++p;
    init(p);
    for(int i = 0; i < (1 << p); ++i){
        if(i < n){
            a[i] = s[i] == 'V';
            b[n - i - 1] = s[i] == 'K';
        }
        else    a[i] = b[i] = 0;
    }
    ntt(a, (1 << p), 0), ntt(b, (1 << p), 0);
    for(int i = 0; i < (1 << p); ++i)    a[i] = a[i] * 1ll * b[i] % mod;
    ntt(a, (1 << p), 1);
    int tot = 0;
    for(int i = 1; i <= n; ++i)  b[i] = a[n - 1 - i] | a[n - 1 + i];    b[n] = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = i * 2; j <= n; j += i)    b[i] |= b[j];
        if(!b[i])   ans[++tot] = i;
    }
    printf("%d\n", tot);
    for(int i = 1; i <= tot; ++i)   printf("%d%c", ans[i], " \n"[i == tot]);
}
int main()
{
    int n;
    scanf("%d", &n);
    while(n--)  solve();
    return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define mod 998244353
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> P;
const LL INF = 0x3f3f3f3f;
const int N = 5e5 + 100; //n = maxn << 2;
const int g[2] = {3, (mod + 1) / 3};
const LL inv2 = mod + 1 >> 1;

inline int add(int a, int b){
    int x = a + b;   return x >= mod ? x - mod : x;
}
inline int pp(int x, int y){
    int ret = 1;
    while(y){
        if(y & 1)   ret = ret * 1ll * x % mod;
        x = x * 1ll * x % mod, y >>= 1;
    }
    return ret;
}

int rev[N];
void init(int p){
    for(int i = 0; i < (1 << p); ++i)    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (p - 1));
}
void ntt(int *a, int n, int op){
    for(int i = 0; i < n; ++i)  if(i < rev[i])  swap(a[i], a[rev[i]]);
    int wn , w;
    for(int i = 1; i < n; i <<= 1){
        wn = pp(g[op], (mod - 1) / (i << 1));
        for(int j = 0; j < n; j += (i << 1)){
            w = 1;
            for(int k = j; k < j + i; ++k){
                LL u = a[k], v = w * 1ll * a[k + i] % mod;
                a[k] = add(u, v), a[k + i] = add(u - v, mod);
                w = w * 1ll * wn % mod;
            }
        }
    }
    if(op)  for(int i = 0, inv = pp(n, mod - 2); i < n; ++i)  a[i] = a[i] * 1ll * inv % mod;
}
int a[N], b[N], ans[N];
char s[N];
void solve(){
    int n, p;
    scanf("%d%s", &n, s);
    p = 0; while((1 << p) < n) ++p; ++p;
    init(p);
    for(int i = 0; i < (1 << p); ++i){
        if(i < n){
            a[i] = s[i] == 'V';
            b[n - i - 1] = s[i] == 'K';
        }
        else    a[i] = b[i] = 0;
    }
    ntt(a, (1 << p), 0), ntt(b, (1 << p), 0);
    for(int i = 0; i < (1 << p); ++i)    a[i] = a[i] * 1ll * b[i] % mod;
    ntt(a, (1 << p), 1);
    int tot = 0;
    for(int i = 1; i <= n; ++i)  b[i] = a[n - 1 - i] | a[n - 1 + i];    b[n] = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = i * 2; j <= n; j += i)    b[i] |= b[j];
        if(!b[i])   ans[++tot] = i;
    }
    printf("%d\n", tot);
    for(int i = 1; i <= tot; ++i)   printf("%d%c", ans[i], " \n"[i == tot]);
}
int main()
{
    int n;
    scanf("%d", &n);
    while(n--)  solve();
    return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define mod 998244353
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> P;
const LL INF = 0x3f3f3f3f;
const int N = 5e5 + 100; //n = maxn << 2;
const int g[2] = {3, (mod + 1) / 3};
const LL inv2 = mod + 1 >> 1;

inline int add(int a, int b){
    int x = a + b;   return x >= mod ? x - mod : x;
}
inline int pp(int x, int y){
    int ret = 1;
    while(y){
        if(y & 1)   ret = ret * 1ll * x % mod;
        x = x * 1ll * x % mod, y >>= 1;
    }
    return ret;
}

int rev[N];
void init(int p){
    for(int i = 0; i < (1 << p); ++i)    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (p - 1));
}
void ntt(int *a, int n, int op){
    for(int i = 0; i < n; ++i)  if(i < rev[i])  swap(a[i], a[rev[i]]);
    int wn , w;
    for(int i = 1; i < n; i <<= 1){
        wn = pp(g[op], (mod - 1) / (i << 1));
        for(int j = 0; j < n; j += (i << 1)){
            w = 1;
            for(int k = j; k < j + i; ++k){
                LL u = a[k], v = w * 1ll * a[k + i] % mod;
                a[k] = add(u, v), a[k + i] = add(u - v, mod);
                w = w * 1ll * wn % mod;
            }
        }
    }
    if(op)  for(int i = 0, inv = pp(n, mod - 2); i < n; ++i)  a[i] = a[i] * 1ll * inv % mod;
}
int a[N], b[N], ans[N];
char s[N];
void solve(){
    int n, p;
    scanf("%d%s", &n, s);
    p = 0; while((1 << p) < n) ++p; ++p;
    init(p);
    for(int i = 0; i < (1 << p); ++i){
        if(i < n){
            a[i] = s[i] == 'V';
            b[n - i - 1] = s[i] == 'K';
        }
        else    a[i] = b[i] = 0;
    }
    ntt(a, (1 << p), 0), ntt(b, (1 << p), 0);
    for(int i = 0; i < (1 << p); ++i)    a[i] = a[i] * 1ll * b[i] % mod;
    ntt(a, (1 << p), 1);
    int tot = 0;
    for(int i = 0; i < n; ++i)  b[n - 1 - i] = a[i];    b[n] = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = i * 2; j <= n; j += i)    b[i] |= b[j];
        if(!b[i])   ans[++tot] = i;
    }
    printf("%d\n", tot);
    for(int i = 1; i <= tot; ++i)   printf("%d%c", ans[i], " \n"[i == tot]);
}
int main()
{
    int n;
    scanf("%d", &n);
    while(n--)  solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;
typedef vector<int> Polynomial;

const int N = (1 << 20) + 3;
const int g = 3, bigp = 479 * (1 << 21) + 1, x = 21;

struct FFTSolver {
  int length_a, length_b;
  int a[N], b[N], w[N], res[N];
  int n;

  int powc(int a, int b) {
    int d;
    if (b == 0) return 1;
    d = powc(a, b / 2);
    d = (Long) d * d % bigp;
    if (b % 2 == 1) d = (Long) d * a % bigp;
    return d;
  }

  inline void fft(int x[], bool inverse) {
    //K is the length of x[]
    //v=0 : DFT,  v=1 : IDFT
    w[0] = 1;
    int G = powc(g, (bigp - 1) / n);
    for (int i = 1; i <= n; i++)
      w[i] = (Long) w[i - 1] * G % bigp;
    for (int i = 0, j = 0; i < n; i++) {
      if (i > j) swap(x[i], x[j]);
      for (int l = n >> 1; (j ^= l) < l; l >>= 1)
        ;
    }
    for (int i = 2; i <= n; i <<= 1)
      for (int j = 0; j < n; j += i)
        for (int l = 0; l < i >> 1; l++) {
          int t;
          if (!inverse)
            t = (Long) x[j + l + (i >> 1)] * w[(n / i) * l] % bigp;
          else
            t = (Long) x[j + l + (i >> 1)] * w[n - (n / i) * l] % bigp;
          x[j + l + (i >> 1)] = ((Long) x[j + l] - t + bigp) % bigp;
          x[j + l] += t;
          x[j + l] %= bigp;
        }
    if (inverse) {
      int r = powc(n, bigp - 2);
      for (int i = 0; i < n; i++)
        x[i] = (Long) x[i] * r % bigp;
    }
  }

  void calculate() {
    //length_a, length_b are length of a[] and b[] (include a[0] and b[0])
    int c = length_a + length_b, l = 0;
    n = 1;
    while (n <= c)
      n *= 2, ++l;
    for (int i = length_a; i < n; i++)
      a[i] = 0;
    for (int i = length_b; i < n; i++)
      b[i] = 0;
    fft(a, 0);
    fft(b, 0);
    for (int i = 0; i < n; i++) {
      res[i] = (Long) a[i] * b[i] % bigp;
    }
    fft(res, 1);
  }

  Polynomial multiply(const Polynomial& a, const Polynomial& b) {
    length_a = a.size();
    length_b = b.size();

    for (int i = 0; i < length_a; ++i) {
      this->a[i] = a[i];
    }

    for (int i = 0; i < length_b; ++i) {
      this->b[i] = b[i];
    }

    calculate();

    return Polynomial(res, res + n);;
  }
} fft_solver;

void print(Polynomial p) {
  cout << "Size: " << p.size() << endl;
  for (int x : p) {
    cout << x << ' ';
  }
  cout << endl;
}

vector<int> getValid(const vector<bool>& invalid) {
  int n = invalid.size() - 1;
  vector<int> res;
  for (int i = 1; i <= n; ++i) {
    bool valid = true;
    for (int j = i; j <= n; j += i) {
      valid &= !invalid[j];
    }
    if (valid) {
      res.push_back(i);
    }
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#endif

  int t;
  cin >> t;

  while (t--) {
    int n;
    cin >> n;

    Polynomial v(n), k(n);
    Polynomial rev_v(n), rev_k(n);

    string s;
    cin >> s;

    for (int i = 0; i < n; ++i) {
      v[i] = rev_v[n - 1 - i] = (s[i] == 'V');
      k[i] = rev_k[n - 1 - i] = (s[i] == 'K');
    }

    Polynomial v_rev_k = fft_solver.multiply(v, rev_k);
    Polynomial k_rev_v = fft_solver.multiply(k, rev_v);

    vector<bool> invalid(n + 1, false);

    for (int i = 0; i < v_rev_k.size(); ++i) {
      if (v_rev_k[i] == 0 && k_rev_v[i] == 0) continue;
      int d = i - n + 1;
      if (d < 1) continue;
      invalid[d] = true;
    }

    auto valid = getValid(invalid);

    cout << valid.size() << '\n';
    for (int x : valid) {
      cout << x << ' ';
    }
    cout << '\n';

  }

}


#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;
typedef vector<int> Polynomial;

const int N = 600005;
const int g = 3, bigp = 479 * (1 << 21) + 1, x = 21;

struct FFTSolver {
  int length_a, length_b;
  int a[N], b[N], w[N], res[N];
  int n;

  int powc(int a, int b) {
    int d;
    if (b == 0) return 1;
    d = powc(a, b / 2);
    d = (Long) d * d % bigp;
    if (b % 2 == 1) d = (Long) d * a % bigp;
    return d;
  }

  inline void fft(int x[], bool inverse) {
    //K is the length of x[]
    //v=0 : DFT,  v=1 : IDFT
    w[0] = 1;
    int G = powc(g, (bigp - 1) / n);
    for (int i = 1; i <= n; i++)
      w[i] = (Long) w[i - 1] * G % bigp;
    for (int i = 0, j = 0; i < n; i++) {
      if (i > j) swap(x[i], x[j]);
      for (int l = n >> 1; (j ^= l) < l; l >>= 1)
        ;
    }
    for (int i = 2; i <= n; i <<= 1)
      for (int j = 0; j < n; j += i)
        for (int l = 0; l < i >> 1; l++) {
          int t;
          if (!inverse)
            t = (Long) x[j + l + (i >> 1)] * w[(n / i) * l] % bigp;
          else
            t = (Long) x[j + l + (i >> 1)] * w[n - (n / i) * l] % bigp;
          x[j + l + (i >> 1)] = ((Long) x[j + l] - t + bigp) % bigp;
          x[j + l] += t;
          x[j + l] %= bigp;
        }
    if (inverse) {
      int r = powc(n, bigp - 2);
      for (int i = 0; i < n; i++)
        x[i] = (Long) x[i] * r % bigp;
    }
  }

  void calculate() {
    //length_a, length_b are length of a[] and b[] (include a[0] and b[0])
    int c = length_a + length_b, l = 0;
    n = 1;
    while (n <= c)
      n *= 2, ++l;
    for (int i = length_a; i < n; i++)
      a[i] = 0;
    for (int i = length_b; i < n; i++)
      b[i] = 0;
    fft(a, 0);
    fft(b, 0);
    for (int i = 0; i < n; i++) {
      res[i] = (Long) a[i] * b[i] % bigp;
    }
    fft(res, 1);
  }

  Polynomial multiply(const Polynomial& a, const Polynomial& b) {
    length_a = a.size();
    length_b = b.size();

    for (int i = 0; i < length_a; ++i) {
      this->a[i] = a[i];
    }

    for (int i = 0; i < length_b; ++i) {
      this->b[i] = b[i];
    }

    calculate();

    return Polynomial(res, res + n);;
  }
} fft_solver;

void print(Polynomial p) {
  cout << "Size: " << p.size() << endl;
  for (int x : p) {
    cout << x << ' ';
  }
  cout << endl;
}

vector<int> factors[N];

vector<int> getFactors(int x) {
  vector<int> res;
  for (int i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      res.push_back(i);
      if (i * i != x) {
        res.push_back(x / i);
      }
    }
  }
  return res;
}

void buildFactors() {
  for (int i = 1; i < N; ++i) {
    factors[i] = getFactors(i);
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#endif

  buildFactors();

  int t;
  cin >> t;

  while (t--) {
    int n;
    cin >> n;

    Polynomial v(n), k(n);
    Polynomial rev_v(n), rev_k(n);

    string s;
    cin >> s;

    for (int i = 0; i < n; ++i) {
      v[i] = rev_v[n - 1 - i] = (s[i] == 'V');
      k[i] = rev_k[n - 1 - i] = (s[i] == 'K');
    }

    Polynomial v_rev_k = fft_solver.multiply(v, rev_k);
    Polynomial k_rev_v = fft_solver.multiply(k, rev_v);

    vector<bool> is_valid(n + 1, true);

    for (int i = 0; i < v_rev_k.size(); ++i) {
      if (v_rev_k[i] == 0 && k_rev_v[i] == 0) continue;
      int d = i - n + 1;
      if (d < 1) continue;
      for (int x : factors[d]) {
        is_valid[x] = false;
      }
    }

    cout << count(is_valid.begin() + 1, is_valid.end(), true) << '\n';
    for (int i = 1; i <= n; ++i) {
      if (is_valid[i]) {
        cout << i << ' ';
      }
    }
    cout << '\n';

  }

}


#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;
typedef vector<int> Polynomial;

const int N = (1 << 20) + 3;
const int g = 3, bigp = 479 * (1 << 21) + 1, x = 21;

struct FFTSolver {
  int length_a, length_b;
  // N must be greater than 1 << (ceil(log2(length_a + length_b)))
  int a[N], b[N], w[N], res[N];
  int n;

  int powc(int a, int b) {
    int d;
    if (b == 0) return 1;
    d = powc(a, b / 2);
    d = (Long) d * d % bigp;
    if (b % 2 == 1) d = (Long) d * a % bigp;
    return d;
  }

  inline void fft(int x[], bool inverse) {
    //K is the length of x[]
    //v=0 : DFT,  v=1 : IDFT
    w[0] = 1;
    int G = powc(g, (bigp - 1) / n);
    for (int i = 1; i <= n; i++)
      w[i] = (Long) w[i - 1] * G % bigp;
    for (int i = 0, j = 0; i < n; i++) {
      if (i > j) swap(x[i], x[j]);
      for (int l = n >> 1; (j ^= l) < l; l >>= 1)
        ;
    }
    for (int i = 2; i <= n; i <<= 1)
      for (int j = 0; j < n; j += i)
        for (int l = 0; l < i >> 1; l++) {
          int t;
          if (!inverse)
            t = (Long) x[j + l + (i >> 1)] * w[(n / i) * l] % bigp;
          else
            t = (Long) x[j + l + (i >> 1)] * w[n - (n / i) * l] % bigp;
          x[j + l + (i >> 1)] = ((Long) x[j + l] - t + bigp) % bigp;
          x[j + l] += t;
          x[j + l] %= bigp;
        }
    if (inverse) {
      int r = powc(n, bigp - 2);
      for (int i = 0; i < n; i++)
        x[i] = (Long) x[i] * r % bigp;
    }
  }

  void calculate() {
    //length_a, length_b are length of a[] and b[] (include a[0] and b[0])
    int c = length_a + length_b;
    n = 1;
    while (n <= c) {
      n *= 2;
    }
    for (int i = length_a; i < n; i++)
      a[i] = 0;
    for (int i = length_b; i < n; i++)
      b[i] = 0;
    fft(a, 0);
    fft(b, 0);
    for (int i = 0; i < n; i++) {
      res[i] = (Long) a[i] * b[i] % bigp;
    }
    fft(res, 1);
  }

  Polynomial multiply(const Polynomial& a, const Polynomial& b) {
    length_a = a.size();
    length_b = b.size();

    for (int i = 0; i < length_a; ++i) {
      this->a[i] = a[i];
    }

    for (int i = 0; i < length_b; ++i) {
      this->b[i] = b[i];
    }

    calculate();

    return Polynomial(res, res + n);;
  }
} fft_solver;

void print(Polynomial p) {
  cout << "Size: " << p.size() << endl;
  for (int x : p) {
    cout << x << ' ';
  }
  cout << endl;
}

vector<int> getValid(const vector<bool>& invalid) {
  int n = invalid.size() - 1;
  vector<int> res;
  for (int i = 1; i <= n; ++i) {
    bool valid = true;
    for (int j = i; j <= n && valid; j += i) {
      valid &= !invalid[j];
    }
    if (valid) {
      res.push_back(i);
    }
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#endif

  int t;
  cin >> t;

  while (t--) {
    int n;
    cin >> n;

    Polynomial v(n), k(n);
    Polynomial rev_v(n), rev_k(n);

    string s;
    cin >> s;

    for (int i = 0; i < n; ++i) {
      v[i] = rev_v[n - 1 - i] = (s[i] == 'V');
      k[i] = rev_k[n - 1 - i] = (s[i] == 'K');
    }

    Polynomial v_rev_k = fft_solver.multiply(v, rev_k);

    vector<bool> invalid(n + 1, false);

    for (int i = 0; i < v_rev_k.size(); ++i) {
      int d = i - n + 1;
      if (d > n) break;
      if (v_rev_k[i] == 0) continue;

      invalid[abs(d)] = true;
    }

    auto valid = getValid(invalid);

    cout << valid.size() << '\n';
    for (int x : valid) {
      cout << x << ' ';
    }
    cout << '\n';

  }

}


#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;
typedef vector<int> Polynomial;

const int N = 600005;
const int g = 3, bigp = 479 * (1 << 21) + 1, x = 21;

struct FFTSolver {
  int length_a, length_b;
  int a[N], b[N], w[N], res[N];
  int n;

  int powc(int a, int b) {
    int d;
    if (b == 0) return 1;
    d = powc(a, b / 2);
    d = (Long) d * d % bigp;
    if (b % 2 == 1) d = (Long) d * a % bigp;
    return d;
  }

  inline void fft(int x[], bool inverse) {
    //K is the length of x[]
    //v=0 : DFT,  v=1 : IDFT
    w[0] = 1;
    int G = powc(g, (bigp - 1) / n);
    for (int i = 1; i <= n; i++)
      w[i] = (Long) w[i - 1] * G % bigp;
    for (int i = 0, j = 0; i < n; i++) {
      if (i > j) swap(x[i], x[j]);
      for (int l = n >> 1; (j ^= l) < l; l >>= 1)
        ;
    }
    for (int i = 2; i <= n; i <<= 1)
      for (int j = 0; j < n; j += i)
        for (int l = 0; l < i >> 1; l++) {
          int t;
          if (!inverse)
            t = (Long) x[j + l + (i >> 1)] * w[(n / i) * l] % bigp;
          else
            t = (Long) x[j + l + (i >> 1)] * w[n - (n / i) * l] % bigp;
          x[j + l + (i >> 1)] = ((Long) x[j + l] - t + bigp) % bigp;
          x[j + l] += t;
          x[j + l] %= bigp;
        }
    if (inverse) {
      int r = powc(n, bigp - 2);
      for (int i = 0; i < n; i++)
        x[i] = (Long) x[i] * r % bigp;
    }
  }

  void calculate() {
    //length_a, length_b are length of a[] and b[] (include a[0] and b[0])
    int c = length_a + length_b, l = 0;
    n = 1;
    while (n <= c)
      n *= 2, ++l;
    for (int i = length_a; i < n; i++)
      a[i] = 0;
    for (int i = length_b; i < n; i++)
      b[i] = 0;
    fft(a, 0);
    fft(b, 0);
    for (int i = 0; i < n; i++) {
      res[i] = (Long) a[i] * b[i] % bigp;
    }
    fft(res, 1);
  }

  Polynomial multiply(const Polynomial& a, const Polynomial& b) {
    length_a = a.size();
    length_b = b.size();

    for (int i = 0; i < length_a; ++i) {
      this->a[i] = a[i];
    }

    for (int i = 0; i < length_b; ++i) {
      this->b[i] = b[i];
    }

    calculate();

    return Polynomial(res, res + n);;
  }
} fft_solver;

void print(Polynomial p) {
  cout << "Size: " << p.size() << endl;
  for (int x : p) {
    cout << x << ' ';
  }
  cout << endl;
}

vector<int> getValid(const vector<bool>& invalid) {
  int n = invalid.size() - 1;
  vector<int> res;
  for (int i = 1; i <= n; ++i) {
    bool valid = true;
    for (int j = i; j <= n; j += i) {
      valid &= !invalid[j];
    }
    if (valid) {
      res.push_back(i);
    }
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#endif

  int t;
  cin >> t;

  while (t--) {
    int n;
    cin >> n;

    Polynomial v(n), k(n);
    Polynomial rev_v(n), rev_k(n);

    string s;
    cin >> s;

    for (int i = 0; i < n; ++i) {
      v[i] = rev_v[n - 1 - i] = (s[i] == 'V');
      k[i] = rev_k[n - 1 - i] = (s[i] == 'K');
    }

    Polynomial v_rev_k = fft_solver.multiply(v, rev_k);
    Polynomial k_rev_v = fft_solver.multiply(k, rev_v);

    vector<bool> invalid(n + 1, false);

    for (int i = 0; i < v_rev_k.size(); ++i) {
      if (v_rev_k[i] == 0 && k_rev_v[i] == 0) continue;
      int d = i - n + 1;
      if (d < 1) continue;
      invalid[d] = true;
    }

    auto valid = getValid(invalid);

    cout << valid.size() << '\n';
    for (int x : valid) {
      cout << x << ' ';
    }
    cout << '\n';

  }

}


#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;
typedef vector<int> Polynomial;

const int N = (1 << 20) + 3;
const int g = 3, bigp = 479 * (1 << 21) + 1, x = 21;

struct FFTSolver {
  int length_a, length_b;
  // N must be greater than 1 << (ceil(log2(length_a + length_b)))
  int a[N], b[N], w[N], res[N];
  int n;

  int powc(int a, int b) {
    int d;
    if (b == 0) return 1;
    d = powc(a, b / 2);
    d = (Long) d * d % bigp;
    if (b % 2 == 1) d = (Long) d * a % bigp;
    return d;
  }

  inline void fft(int x[], bool inverse) {
    //K is the length of x[]
    //v=0 : DFT,  v=1 : IDFT
    w[0] = 1;
    int G = powc(g, (bigp - 1) / n);
    for (int i = 1; i <= n; i++)
      w[i] = (Long) w[i - 1] * G % bigp;
    for (int i = 0, j = 0; i < n; i++) {
      if (i > j) swap(x[i], x[j]);
      for (int l = n >> 1; (j ^= l) < l; l >>= 1)
        ;
    }
    for (int i = 2; i <= n; i <<= 1)
      for (int j = 0; j < n; j += i)
        for (int l = 0; l < i >> 1; l++) {
          int t;
          if (!inverse)
            t = (Long) x[j + l + (i >> 1)] * w[(n / i) * l] % bigp;
          else
            t = (Long) x[j + l + (i >> 1)] * w[n - (n / i) * l] % bigp;
          x[j + l + (i >> 1)] = ((Long) x[j + l] - t + bigp) % bigp;
          x[j + l] += t;
          x[j + l] %= bigp;
        }
    if (inverse) {
      int r = powc(n, bigp - 2);
      for (int i = 0; i < n; i++)
        x[i] = (Long) x[i] * r % bigp;
    }
  }

  void calculate() {
    //length_a, length_b are length of a[] and b[] (include a[0] and b[0])
    int c = length_a + length_b;
    n = 1;
    while (n <= c) {
      n *= 2;
    }
    for (int i = length_a; i < n; i++)
      a[i] = 0;
    for (int i = length_b; i < n; i++)
      b[i] = 0;
    fft(a, 0);
    fft(b, 0);
    for (int i = 0; i < n; i++) {
      res[i] = (Long) a[i] * b[i] % bigp;
    }
    fft(res, 1);
  }

  Polynomial multiply(const Polynomial& a, const Polynomial& b) {
    length_a = a.size();
    length_b = b.size();

    for (int i = 0; i < length_a; ++i) {
      this->a[i] = a[i];
    }

    for (int i = 0; i < length_b; ++i) {
      this->b[i] = b[i];
    }

    calculate();

    return Polynomial(res, res + n);;
  }
} fft_solver;

void print(Polynomial p) {
  cout << "Size: " << p.size() << endl;
  for (int x : p) {
    cout << x << ' ';
  }
  cout << endl;
}

vector<int> getValid(const vector<bool>& invalid) {
  int n = invalid.size() - 1;
  vector<int> res;
  for (int i = 1; i <= n; ++i) {
    bool valid = true;
    for (int j = i; j <= n && valid; j += i) {
      valid &= !invalid[j];
    }
    if (valid) {
      res.push_back(i);
    }
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#endif

  int t;
  cin >> t;

  while (t--) {
    int n;
    cin >> n;

    Polynomial v(n), k(n);
    Polynomial rev_v(n), rev_k(n);

    string s;
    cin >> s;

    for (int i = 0; i < n; ++i) {
      v[i] = rev_v[n - 1 - i] = (s[i] == 'V');
      k[i] = rev_k[n - 1 - i] = (s[i] == 'K');
    }

    Polynomial v_rev_k = fft_solver.multiply(v, rev_k);
    Polynomial k_rev_v = fft_solver.multiply(k, rev_v);

    vector<bool> invalid(n + 1, false);

    for (int i = 0; i < v_rev_k.size(); ++i) {
      int d = i - n + 1;
      if (d > n) break;
      if (d < 1) continue;
      if (v_rev_k[i] == 0 && k_rev_v[i] == 0) continue;

      invalid[d] = true;
    }

    auto valid = getValid(invalid);

    cout << valid.size() << '\n';
    for (int x : valid) {
      cout << x << ' ';
    }
    cout << '\n';

  }

}


#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;
typedef vector<int> Polynomial;

typedef double Double;

struct Complex {
  Double real, imag;
  Complex() :
    real(0), imag(0) {
  }
  Complex(Double n) :
    real(n), imag(0) {
  }
  Complex(Double r, Double i) :
    real(r), imag(i) {
  }
  Complex operator +(Complex b) {
    return Complex(real + b.real, imag + b.imag);
  }
  Complex operator +=(Complex b) {
    real += b.real, imag += b.imag;
    return *this;
  }
  Complex operator -(Complex b) {
    return Complex(real - b.real, imag - b.imag);
  }
  Complex operator *(Complex b) {
    return Complex(real * b.real - imag * b.imag, real * b.imag + imag * b.real);
  }
  Complex operator /(Double n) {
    return Complex(real / n, imag / n);
  }
  Complex operator *=(Complex b) {
    return (*this) = (*this) * b;
  }
  Complex operator /=(Double n) {
    return (*this) = (*this) / n;
  }
};

namespace FFTSolver {
const int MAXN = 1 << 20;

void fft(vector<Complex>& a, int n, int invert) {
  static Double PI = 2 * acos((Double) 0);
  for (int i = 1, j = 0; i < n; i++) {
    for (int s = n; j ^= s >>= 1, ~j & s;)
      ;
    if (i < j) swap(a[i], a[j]);
  }
  for (int m = 1; m < n; m <<= 1) {
    Double p = PI / m * (invert ? -1 : 1);
    Complex w = Complex(cos(p), sin(p));
    for (int i = 0; i < n; i += m << 1) {
      Complex unit = 1;
      for (int j = 0; j < m; j++) {
        Complex& x = a[i + j + m], &y = a[i + j], t = unit * x;
        x = y - t;
        y = y + t;
        unit *= w;
      }
    }
  }
  if (invert) for (int i = 0; i < n; i++)
    a[i] /= n;
}

Polynomial multiply(const Polynomial& a, const Polynomial& b) {
  int na = a.size();
  int nb = b.size();

  static vector<Complex> fa(MAXN << 1), fb(MAXN << 1);
  int n = 1;
  while (n < na + nb - 1)
    n <<= 1;
  for (int i = 0; i < n; i++)
    fa[i] = fb[i] = Complex(0);
  for (int i = 0; i < na; i++)
    fa[i] = Complex(a[i]);
  for (int i = 0; i < nb; i++)
    fb[i] = Complex(b[i]);
  fft(fa, n, 0);
  fft(fb, n, 0);
  for (int i = 0; i < n; i++)
    fa[i] *= fb[i];
  fft(fa, n, 1);

  Polynomial res(n);
  for (int i = 0; i < n; i++)
    res[i] = (fa[i].real + 0.5);
  return res;
}
}

void print(Polynomial p) {
  cout << "Size: " << p.size() << endl;
  for (int x : p) {
    cout << x << ' ';
  }
  cout << endl;
}

vector<int> getValid(const vector<bool>& invalid) {
  int n = invalid.size() - 1;
  vector<int> res;
  for (int i = 1; i <= n; ++i) {
    bool valid = true;
    for (int j = i; j <= n && valid; j += i) {
      valid &= !invalid[j];
    }
    if (valid) {
      res.push_back(i);
    }
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#endif

  int t;
  cin >> t;

  while (t--) {
    int n;
    cin >> n;

    Polynomial v(n), k(n);
    Polynomial rev_v(n), rev_k(n);

    string s;
    cin >> s;

    for (int i = 0; i < n; ++i) {
      v[i] = rev_v[n - 1 - i] = (s[i] == 'V');
      k[i] = rev_k[n - 1 - i] = (s[i] == 'K');
    }

    Polynomial v_rev_k = FFTSolver::multiply(v, rev_k);

    vector<bool> invalid(n + 1, false);

    for (int i = 0; i < v_rev_k.size(); ++i) {
      int d = i - n + 1;
      if (d > n) break;
      if (v_rev_k[i] == 0) continue;

      invalid[abs(d)] = true;
    }

    auto valid = getValid(invalid);

    cout << valid.size() << '\n';
    for (int x : valid) {
      cout << x << ' ';
    }
    cout << '\n';

  }

}


#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;
typedef vector<int> Polynomial;

const int N = 600005;
const int g = 3, bigp = 479 * (1 << 21) + 1, x = 21;

struct FFTSolver {
  int length_a, length_b;
  int a[N], b[N], w[N], res[N];
  int n;

  int powc(int a, int b) {
    int d;
    if (b == 0) return 1;
    d = powc(a, b / 2);
    d = (Long) d * d % bigp;
    if (b % 2 == 1) d = (Long) d * a % bigp;
    return d;
  }

  inline void fft(int x[], bool inverse) {
    //K is the length of x[]
    //v=0 : DFT,  v=1 : IDFT
    w[0] = 1;
    int G = powc(g, (bigp - 1) / n);
    for (int i = 1; i <= n; i++)
      w[i] = (Long) w[i - 1] * G % bigp;
    for (int i = 0, j = 0; i < n; i++) {
      if (i > j) swap(x[i], x[j]);
      for (int l = n >> 1; (j ^= l) < l; l >>= 1)
        ;
    }
    for (int i = 2; i <= n; i <<= 1)
      for (int j = 0; j < n; j += i)
        for (int l = 0; l < i >> 1; l++) {
          int t;
          if (!inverse)
            t = (Long) x[j + l + (i >> 1)] * w[(n / i) * l] % bigp;
          else
            t = (Long) x[j + l + (i >> 1)] * w[n - (n / i) * l] % bigp;
          x[j + l + (i >> 1)] = ((Long) x[j + l] - t + bigp) % bigp;
          x[j + l] += t;
          x[j + l] %= bigp;
        }
    if (inverse) {
      int r = powc(n, bigp - 2);
      for (int i = 0; i < n; i++)
        x[i] = (Long) x[i] * r % bigp;
    }
  }

  void calculate() {
    //length_a, length_b are length of a[] and b[] (include a[0] and b[0])
    int c = length_a + length_b, l = 0;
    n = 1;
    while (n <= c)
      n *= 2, ++l;
    for (int i = length_a; i < n; i++)
      a[i] = 0;
    for (int i = length_b; i < n; i++)
      b[i] = 0;
    fft(a, 0);
    fft(b, 0);
    for (int i = 0; i < n; i++) {
      res[i] = (Long) a[i] * b[i] % bigp;
    }
    fft(res, 1);
  }

  Polynomial multiply(const Polynomial& a, const Polynomial& b) {
    length_a = a.size();
    length_b = b.size();

    for (int i = 0; i < length_a; ++i) {
      this->a[i] = a[i];
    }

    for (int i = 0; i < length_b; ++i) {
      this->b[i] = b[i];
    }

    calculate();

    return Polynomial(res, res + n);;
  }
} fft_solver;

void print(Polynomial p) {
  cout << "Size: " << p.size() << endl;
  for (int x : p) {
    cout << x << ' ';
  }
  cout << endl;
}

vector<int> factors[N];

vector<int> getFactors(int x) {
  vector<int> res;
  for (int i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      res.push_back(i);
      if (i * i != x) {
        res.push_back(x / i);
      }
    }
  }
  return res;
}

void buildFactors() {
  for (int i = 1; i < N; ++i) {
    factors[i] = getFactors(i);
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#endif

  buildFactors();

  int t;
  cin >> t;

  while (t--) {
    int n;
    cin >> n;

    Polynomial v(n), k(n);
    Polynomial rev_v(n), rev_k(n);

    string s;
    cin >> s;

    for (int i = 0; i < n; ++i) {
      v[i] = rev_v[n - 1 - i] = (s[i] == 'V');
      k[i] = rev_k[n - 1 - i] = (s[i] == 'K');
    }

    Polynomial v_rev_k = fft_solver.multiply(v, rev_k);
    Polynomial k_rev_v = fft_solver.multiply(k, rev_v);

    set<int> valid;
    for (int i = 1; i <= n; ++i) {
      valid.insert(i);
    }

    for (int i = 0; i < v_rev_k.size(); ++i) {
      if (v_rev_k[i] == 0 && k_rev_v[i] == 0) continue;
      int d = i - n + 1;
      if (d < 1) continue;
      for (int x : factors[d]) {
        valid.erase(x);
      }
    }

    cout << valid.size() << '\n';
    for (int x : valid) {
      cout << x << ' ';
    }
    cout << '\n';

  }

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef unsigned int ui;
typedef vector <int> vi;
const ll mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const ll INF = 1e18;

int t;
#define maxn 500100
char s[maxn];
int n;
const int C = 30;

bool block[maxn];
vi V, K;
const int MAX = 3e8;

int main()
{
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d", &n);
		scanf("%s", s + 1);
		V.clear(); K.clear();
		FOR(i, 1, n)
		{
			block[i] = 0;
			if (s[i] == 'V') V.pb(i);
			if (s[i] == 'K') K.pb(i);
		}
		ll vsz = (int)V.size(), ksz = (int)K.size();
		if (vsz * ksz <= 200 * n)
		{
			for (auto v : V)
				for (auto k : K) block[abs(v - k)] = 1;
		}
		else
		{
			for (auto v : V)
			{
				vi :: iterator it = K.begin();
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
				it = K.end(); --it;
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
			}
			random_shuffle(K.begin(), K.end());
			for (auto v : V)
			{
				vi :: iterator it = K.begin();
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
				it = K.end(); --it;
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
			}
			//lol;
		}
		int bs = 0;
		for (int i=n; i>0; --i)
		{
			if (!block[i])
			{
				for (int j = i + i; j <= n; j += i) block[i] |= block[j];
			}
			if (!block[i]) ++bs;
		}

		cout << bs << "\n";
		FOR(i, 1, n) if (!block[i]) cout << i << ' ';
		cout << "\n";
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef unsigned int ui;
typedef vector <int> vi;
const ll mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const ll INF = 1e18;

int t;
#define maxn 500100
char s[maxn];
int n;
const int C = 200;

bool block[maxn];
vi V, K;
const int MAX = 3e8;

int main()
{
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d", &n);
		scanf("%s", s + 1);
		V.clear(); K.clear();
		FOR(i, 1, n)
		{
			block[i] = 0;
			if (s[i] == 'V') V.pb(i);
			if (s[i] == 'K') K.pb(i);
		}
		ll vsz = (int)V.size(), ksz = (int)K.size();
		if (vsz * ksz <= 200 * n)
		{
			for (auto v : V)
				for (auto k : K) block[abs(v - k)] = 1;
		}
		else
		{
			for (auto v : V)
			{
				vi :: iterator it = K.begin();
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
				it = K.end(); --it;
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
			}
			random_shuffle(K.begin(), K.end());
			for (auto v : V)
			{
				vi :: iterator it = K.begin();
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
				it = K.end(); --it;
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
			}
			//lol;
		}
		int bs = 0;
		for (int i=n; i>0; --i)
		{
			if (!block[i])
			{
				for (int j = i + i; j <= n; j += i) block[i] |= block[j];
			}
			if (!block[i]) ++bs;
		}

		cout << bs << "\n";
		FOR(i, 1, n) if (!block[i]) cout << i << ' ';
		cout << "\n";
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef unsigned int ui;
typedef vector <int> vi;
const ll mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const ll INF = 1e18;

int t;
#define maxn 500100
char s[maxn];
int n;
const int C = 200;

bool block[maxn];
vi V, K;
const int MAX = 3e8;

int main()
{
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d", &n);
		scanf("%s", s + 1);
		V.clear(); K.clear();
		FOR(i, 1, n)
		{
			block[i] = 0;
			if (s[i] == 'V') V.pb(i);
			if (s[i] == 'K') K.pb(i);
		}
		ll vsz = (int)V.size(), ksz = (int)K.size();
		if (vsz * ksz <= 200 * n)
		{
			for (auto v : V)
				for (auto k : K) block[abs(v - k)] = 1;
		}
		else
		{
			assert(1 == 0);
			for (auto v : V)
			{
				vi :: iterator it = K.begin();
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
				it = K.end(); --it;
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
			}
			random_shuffle(K.begin(), K.end());
			for (auto v : V)
			{
				vi :: iterator it = K.begin();
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
				it = K.end(); --it;
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
			}
			//lol;
		}
		int bs = 0;
		for (int i=n; i>0; --i)
		{
			if (!block[i])
			{
				for (int j = i + i; j <= n; j += i) block[i] |= block[j];
			}
			if (!block[i]) ++bs;
		}

		cout << bs << "\n";
		FOR(i, 1, n) if (!block[i]) cout << i << ' ';
		cout << "\n";
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef unsigned int ui;
typedef vector <int> vi;
const ll mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const ll INF = 1e18;

int t;
#define maxn 500100
char s[maxn];
int n;
bool block[maxn];
vi V, K;
const int MAX = 3e8;

int main()
{
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d", &n);
		scanf("%s", s + 1);
		V.clear(); K.clear();
		FOR(i, 1, n)
		{
			block[i] = 0;
			if (s[i] == 'V') V.pb(i);
			if (s[i] == 'K') K.pb(i);
		}
		ll vsz = (int)V.size(), ksz = (int)K.size();
		if (vsz * ksz <= 200 * n)
		{
			for (auto v : V)
				for (auto k : K) block[abs(v - k)] = 1;
		}
		else
		{
			int C = min(200, (int)ksz);
			for (auto v : V)
			{
				vi :: iterator it = K.begin();
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
				it = K.end(); --it;
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					--it;
				}
			}
			random_shuffle(K.begin(), K.end());
			for (auto v : V)
			{
				vi :: iterator it = K.begin();
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					++it;
				}
				it = K.end(); --it;
				for (int help = 1; help <= C; ++help)
				{
					block[abs(v - *it)] = 1;
					--it;
				}
			}
			//lol;
		}
		int bs = 0;
		for (int i=n; i>0; --i)
		{
			if (!block[i])
			{
				for (int j = i + i; j <= n; j += i) block[i] |= block[j];
			}
			if (!block[i]) ++bs;
		}

		cout << bs << "\n";
		FOR(i, 1, n) if (!block[i]) cout << i << ' ';
		cout << "\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<double> base;

const double PI = acos(-1.0);
base wlen_pow[524300];

void fft(vector<base>& a, bool invert) {
    int n = (int)a.size();

    for (int i = 1, j = 0; i < n; ++i) {
        int bit = n >> 1;
        for (; j >= bit; bit >>= 1)
            j -= bit;
        j += bit;
        if (i < j)
            swap(a[i], a[j]);
    }

    for (int len = 1; len < n; len <<= 1) {
        double angle = PI / len;
        if (invert)
            angle = -angle;
        base wlen(cos(angle), sin(angle));
        wlen_pow[0] = base(1);
        for (int i = 1; i < (n >> 1); ++i)
            wlen_pow[i] = wlen_pow[i - 1] * wlen;
        for (int i = 0; i < n; i += len << 1) {
            for (int j = 0; j < len; ++j) {
                base u = a[i + j];
                base v = a[i + j + len] * wlen_pow[j];
                a[i + j] = u + v;
                a[i + j + len] = u - v;
            }
        }
    }

    if (invert)
        for (int i = 0; i < n; ++i)
            a[i] /= n;
}

void multiply(const vector<int>& a, const vector<int>& b, vector<int>& res) {
    size_t max_size = max(a.size(), b.size());
    size_t n = 1;
    while (n < max_size)
        n <<= 1;
    n <<= 1;

    vector<base> fa(n), fb(n);
    for (size_t i = a.size(); i--; )
        fa[i] = a[i];
    for (size_t i = b.size(); i--; )
        fb[i] = b[i];
    fft(fa, false);
    fft(fb, false);
    for (size_t i = 0; i < n; ++i)
        fa[i] *= fb[i];
    fft(fa, true);

    res.resize(n);
    for (size_t i = 0; i < n; ++i)
        res[i] = (int)round(fa[i].real());
}

int main()
{
    int t;
    cin >> t;
    while (t--) {
        int n;
        string s;
        cin >> n >> s;
        vector<int> va(n + 1), vb(n + 1);
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'V')
                va[i] = 1;
            else if (s[i] == 'K')
                vb[n - i] = 1;
        }
        vector<int> periods(n + 1), ans;
        vector<int> v = multiply(va, vb);
        for (int i = 1; i < 2 * n; ++i)
            if (v[i])
                periods[abs(n - i)] = 1;
        for (int i = 1; i <= n; ++i) {
            bool good = true;
            for (int j = i; j <= n; j += i) {
                if (periods[j]) {
                    good = false;
                    break;
                }
            }
            if (good)
                ans.push_back(i);
        }

        cout << ans.size() << "\n";
        for (int x : ans)
            cout << x << " ";
        cout << "\n";
    }
    return 0;
}