#include <bits/stdc++.h>
using namespace std;
int n, t;
string s;
bool ans[500007];
complex<double> a[1 << 20], b[1 << 20], ya[1 << 20], yb[1 << 20], tmp[1 << 20];
void fft(int n, complex<double> *a, complex<double> *y, bool inv, int p = 0,
         int s = 1, int q = 0) {
  if (n == 1) {
    y[q] = a[p];
    return;
  }
  fft(n / 2, a, y, inv, p, 2 * s, q);
  fft(n / 2, a, y, inv, p + s, 2 * s, q + n / 2);
  complex<double> w = 1, wn = exp(complex<double>(
                             0, (inv ? -1 : 1) * 2 * acos(-1) / n));
  for (int i = 0; i < n / 2; ++i) {
    tmp[i] = y[q + i] + w * y[q + n / 2 + i];
    tmp[i + n / 2] = y[q + i] - w * y[q + n / 2 + i];
    w *= wn;
  }
  for (int i = 0; i < n; ++i) {
    y[q + i] = tmp[i];
  }
}
void solve() {
  cin >> n >> s;
  int d = (1 << (31 - __builtin_clz(n))) * (__builtin_popcount(n) == 1 ? 1 : 2);
  for (int i = 0; i < 2 * d; ++i) {
    a[i] = b[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'V')
      a[i] = complex<double>(1, 0);
    else if (s[i] == 'K')
      b[n - i] = complex<double>(1, 0);
  }
  fft(2 * d, a, ya, 0);
  fft(2 * d, b, yb, 0);
  for (int i = 0; i < 2 * d; ++i) {
    ya[i] *= yb[i];
  }
  fft(2 * d, ya, a, 1);
  for (int i = n + 1; i < 2 * d; ++i) {
    if ((int)a[i].real()) ans[i - n] = 1;
  }
  for (int i = 0; i < 2 * d; ++i) {
    a[i] = b[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'V')
      a[n - i] = complex<double>(1, 0);
    else if (s[i] == 'K')
      b[i] = complex<double>(1, 0);
  }
  fft(2 * d, a, ya, 0);
  fft(2 * d, b, yb, 0);
  for (int i = 0; i < 2 * d; ++i) {
    ya[i] *= yb[i];
  }
  fft(2 * d, ya, a, 1);
  for (int i = n + 1; i < 2 * d; ++i) {
    if ((int)a[i].real()) ans[i - n] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 2 * i; j <= n; j += i) {
      ans[i] |= ans[j];
    }
  }
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    if (!ans[i]) ++res;
  }
  cout << res << '\n';
  for (int i = 1; i <= n; ++i) {
    if (!ans[i]) cout << i << " ";
    ans[i] = 0;
  }
  cout << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> t;
  while (t--) solve();
}
