#include <bits/stdc++.h>
using namespace std;
const long long mod = (119 << 23) + 1, root = 3;
long long modpow(long long a, long long e) {
  if (e == 0) return 1;
  long long x = modpow(a * a % mod, e >> 1);
  return e & 1 ? x * a % mod : x;
}
void ntt(long long* x, long long* temp, long long* roots, int N, int skip) {
  if (N == 1) return;
  int n2 = N / 2;
  ntt(x, temp, roots, n2, skip * 2);
  ntt(x + skip, temp, roots, n2, skip * 2);
  for (int i = 0; i < (N); ++i) temp[i] = x[i * skip];
  for (int i = 0; i < (n2); ++i) {
    long long s = temp[2 * i], t = temp[2 * i + 1] * roots[skip * i];
    x[skip * i] = (s + t) % mod;
    x[skip * (i + n2)] = (s - t) % mod;
  }
}
void ntt(vector<long long>& x, bool inv = false) {
  long long e = modpow(root, (mod - 1) / (int)(x).size());
  if (inv) e = modpow(e, mod - 2);
  vector<long long> roots((int)(x).size(), 1), temp = roots;
  for (int i = 1; i < ((int)(x).size()); ++i) roots[i] = roots[i - 1] * e % mod;
  ntt(&x[0], &temp[0], &roots[0], (int)(x).size(), 1);
}
vector<long long> conv(vector<long long> a, vector<long long> b) {
  int s = (int)(a).size() + (int)(b).size() - 1;
  if (s <= 0) return {};
  int L = s > 1 ? 32 - __builtin_clz(s - 1) : 0, n = 1 << L;
  if (s <= 200) {
    vector<long long> c(s);
    for (int i = 0; i < ((int)(a).size()); ++i)
      for (int j = 0; j < ((int)(b).size()); ++j)
        c[i + j] = (c[i + j] + a[i] * b[j]) % mod;
    return c;
  }
  a.resize(n);
  ntt(a);
  b.resize(n);
  ntt(b);
  vector<long long> c(n);
  long long d = modpow(n, mod - 2);
  for (int i = 0; i < (n); ++i) c[i] = a[i] * b[i] % mod * d % mod;
  ntt(c, true);
  c.resize(s);
  return c;
}
vector<long long> v1, v2, v3;
char str[550000];
int ok[550000];
int bad[550000];
int main() {
  int T;
  scanf("%d", &T);
  for (int t = 0; t < T; t++) {
    v1.clear();
    v2.clear();
    v3.clear();
    int n;
    scanf("%d%s", &n, str);
    for (int i = 1; i <= n; i++) {
      ok[i] = 1;
      bad[i] = 1;
    }
    for (int i = 0; i < n; i++) {
      v1.push_back(str[i] == 'V');
    }
    for (int i = 0; i < n; i++) {
      v2.push_back(str[n - 1 - i] == 'K');
    }
    v3 = conv(v1, v2);
    for (int i = 0; i < v3.size(); i++) {
      v3[i] %= mod;
      if (v3[i] == 0) continue;
      bad[abs(i - (n - 1))] = 0;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j += i) {
        ok[i] &= bad[j];
      }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += ok[i];
    }
    printf("%d\n", ans);
    for (int i = 1; i <= n; i++) {
      if (ok[i]) {
        printf("%d", i);
        ans--;
        if (ans > 0) printf(" ");
      }
    }
    cout << endl;
  }
}
