#include <bits/stdc++.h>
using namespace std;
const int maxn = 500050;
int a[maxn], b[maxn];
int rev[3 * maxn];
complex<double> w[3 * maxn];
double pi;
void print(vector<complex<double> > &a) {
  cout << (int)a.size() << endl;
  for (int i = 0; i < (int)a.size(); i++) {
    cout << a[i].real() << " ";
  }
  cout << endl;
}
inline vector<complex<double> > fft(vector<complex<double> > &a1) {
  int n = (int)a1.size(), ln = 0;
  while ((1 << (ln + 1)) < n) {
    ln++;
  }
  rev[0] = 0;
  w[0] = complex<double>(cos(0), sin(0));
  double ang;
  for (int i = 1; i < n; i++) {
    rev[i] = rev[i / 2] / 2 + (1 << ln) * (i % 2);
    ang = 2.0 * pi * i / n;
    w[i] = complex<double>(cos(ang), sin(ang));
  }
  vector<complex<double> > cur(n);
  for (int i = 0; i < n; i++) {
    cur[i] = a1[rev[i]];
  }
  complex<double> val;
  for (int len = 1; len < n; len <<= 1) {
    vector<complex<double> > ncur(n);
    int rstep = n / (len * 2);
    for (int p1 = 0; p1 < n; p1 += len) {
      for (int i = 0; i < len; i++) {
        val = w[i * rstep] * cur[p1 + len];
        ncur[p1] = cur[p1] + val;
        ncur[p1 + len] = cur[p1] - val;
        p1++;
      }
    }
    cur.swap(ncur);
  }
  return cur;
}
inline vector<complex<double> > fftRev(vector<complex<double> > &a1) {
  vector<complex<double> > res = fft(a1);
  reverse(res.begin() + 1, res.end());
  for (int i = 0; i < (int)res.size(); i++) {
    res[i] /= (double)res.size();
  }
  return res;
}
inline vector<complex<double> > mult(vector<complex<double> > &a,
                                     vector<complex<double> > &b) {
  vector<complex<double> > a1 = fft(a);
  vector<complex<double> > b1 = fft(b);
  for (int i = 0; i < (int)a1.size(); i++) {
    a1[i] *= b1[i];
  }
  return fftRev(a1);
}
int res[maxn];
char s[maxn];
inline void solve(int n) {
  int m = 1;
  while (m < n) {
    m <<= 1;
  }
  m <<= 1;
  vector<complex<double> > a(m, complex<double>(0, 0)),
      b(m, complex<double>(0, 0)), c;
  for (int i = 0; i < n; i++) {
    res[i] = 0;
    if (s[i] == 'V') {
      a[i] = complex<double>(1, 0);
    }
    if (s[i] == 'K') {
      b[n - i] = complex<double>(1, 0);
    }
  }
  c = mult(a, b);
  res[n] = 0;
  for (int i = 1; i < n + n; i++) {
    if (i < n) {
      res[n - i] += (int)(c[i].real() + 0.5);
    } else {
      res[i - n] += (int)(c[i].real() + 0.5);
    }
  }
  vector<int> ans;
  ans.clear();
  for (int i = 1; i <= n; i++) {
    ans.push_back(i);
    for (int j = i; j <= n; j += i) {
      if (res[j]) {
        ans.pop_back();
        break;
      }
    }
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); i++) {
    printf("%d ", ans[i]);
  }
  puts("");
}
int main() {
  pi = acos(-1.0);
  int T, ln;
  cin >> T;
  while (T--) {
    scanf("%d\n", &ln);
    gets(s);
    solve(ln);
  }
  return 0;
}
