#include <bits/stdc++.h>
using namespace std;
const int LOG = 20;
const int N = 1 << LOG;
complex<double> w[N];
complex<double> F[2][N];
int rev[N];
double PI = acos(-1);
int ans[N];
int c[N];
void initFFT() {
  for (int i = 0; i < N; i++) {
    double angle = 2 * PI * i / N;
    w[i] = complex<double>(cos(angle), sin(angle));
  }
  rev[0] = 0;
  int k = 0;
  for (int i = 1; i < N; i++) {
    if (i == (1 << (k + 1))) k++;
    rev[i] = rev[i ^ (1 << k)] | (1 << (LOG - 1 - k));
  }
}
void FFT(complex<double>* A, int k) {
  int L = 1 << k;
  for (int i = 0; i < L; i++) {
    F[0][rev[i] >> (LOG - k)] = A[i];
  }
  int t = 0;
  int nt = 1;
  for (int lvl = 0; lvl < k; lvl++) {
    int len = 1 << lvl;
    for (int st = 0; st < L; st += (len << 1)) {
      for (int i = 0; i < len; i++) {
        complex<double> add = F[t][st + len + i] * w[i << (LOG - 1 - lvl)];
        F[nt][st + i] = F[t][st + i] + add;
        F[nt][st + len + i] = F[t][st + i] - add;
      }
    }
    swap(t, nt);
  }
  for (int i = 0; i < L; i++) {
    A[i] = F[t][i];
  }
}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int k = 0;
  while ((1 << k) < 2 * n) k++;
  int len = 1 << k;
  complex<double> a[len];
  complex<double> b[len];
  for (int i = 0; i < len; i++) {
    a[i] = b[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == 'V')
      a[i] = 1;
    else if (s[i] == 'K')
      b[n - 1 - i] = 1;
  }
  FFT(a, k);
  FFT(b, k);
  for (int i = 0; i < len; i++) {
    a[i] *= b[i];
  }
  FFT(a, k);
  for (int i = 0; i < len; i++) {
    c[i] = (int)(a[i].real() / len + 0.5);
  }
  reverse(c + 1, c + len);
  for (int i = 1; i <= n; i++) {
    ans[i] = 1;
  }
  for (int i = 0; i < len; i++) {
    if (c[i] != 0) {
      int ind = abs(n - 1 - i);
      if (ind <= n) ans[ind] = 0;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      ans[i] &= ans[j];
    }
    cnt += ans[i];
  }
  cout << cnt << "\n";
  for (int i = 1; i <= n; i++) {
    if (ans[i]) cout << i << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  initFFT();
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
