#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 20, inf = 1e9 + 233, mod = 998244353;
int T, n, N;
int a[maxn], b[maxn], ans[maxn], w[maxn];
char s[maxn];
template <typename T>
inline void read(T &k) {
  int f = 1;
  k = 0;
  char c = getchar();
  while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
  while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
  k *= f;
}
inline int power(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) ans = 1ll * a * ans % mod;
  return ans;
}
inline void ntt(int *a, int f) {
  for (int i = 0, j = 0; i < N; i++) {
    if (i < j) swap(a[i], a[j]);
    for (int k = N >> 1; (j ^= k) < k; k >>= 1)
      ;
  }
  for (int i = 2; i <= N; i <<= 1) {
    int m = i >> 1, base = power(3, (mod - 1) / i);
    if (f == -1) base = power(base, mod - 2);
    w[0] = 1;
    for (int j = 1; j < m; j++) w[j] = 1ll * w[j - 1] * base % mod;
    for (int j = 0; j < N; j += i) {
      for (int k = 0; k < m; k++) {
        int t = 1ll * a[j + k + m] * w[k] % mod;
        a[j + k + m] =
            ((a[j + k] - t + mod) >= mod ? ((a[j + k] - t + mod) - mod)
                                         : (a[j + k] - t + mod));
        a[j + k] =
            ((a[j + k] + t) >= mod ? ((a[j + k] + t) - mod) : (a[j + k] + t));
      }
    }
  }
  if (f == -1)
    for (int i = 0, inv = power(N, mod - 2); i < N; i++)
      a[i] = 1ll * a[i] * inv % mod;
}
inline void solve() {
  read(n);
  scanf("%s", s);
  for (int i = 0; i < n; i++)
    a[n - 1 - i] = (s[i] == 'V'), b[i] = (s[i] == 'K');
  for (N = 1; N < (n << 1); N <<= 1)
    ;
  for (int i = n; i < N; i++) a[i] = b[i] = 0;
  ntt(a, 1);
  ntt(b, 1);
  for (int i = 0; i < N; i++) a[i] = 1ll * a[i] * b[i] % mod;
  ntt(a, -1);
  for (int i = 1; i < n; i++) {
    bool flag = 0;
    for (int j = i; j < n; j += i) flag |= !!a[n - 1 - j] || !!a[n - 1 + j];
    if (!flag) ans[++ans[0]] = i;
  }
  ans[++ans[0]] = n;
  printf("%d\n", ans[0]);
  for (int i = 1; i <= ans[0]; i++) printf("%d ", ans[i]);
  puts("");
}
inline void clear() { ans[0] = 0; }
int main() {
  read(T);
  while (T--) clear(), solve();
}
