#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2002000;
const long long mod = 998244353;
const long long g = 3;
int nn;
long long x1[MAXN], x2[MAXN];
inline long long mul(long long x, long long y) { return x * y % mod; }
long long power(long long a, long long b) {
  long long res = 1, tmp = a;
  while (b) {
    if (b & 1) res = mul(res, tmp);
    tmp = mul(tmp, tmp);
    b >>= 1;
  }
  return res;
}
void DFT(long long y[], int n, bool rev) {
  for (int i = 1, j, t, k; i < n; ++i) {
    for (k = n >> 1, t = i, j = 0; k; k >>= 1, t >>= 1) {
      j = j << 1 | t & 1;
    }
    if (i < j) swap(y[i], y[j]);
  }
  for (int s = 2, ds = 1; s <= n; ds = s, s <<= 1) {
    long long wn = power(g, (mod - 1) / s);
    if (!rev) wn = power(wn, mod - 2);
    for (int k = 0; k < n; k += s) {
      long long w = 1, t;
      for (int i = k; i < k + ds; ++i, w = mul(w, wn)) {
        y[i + ds] = (y[i] - (t = mul(y[i + ds], w)) + mod) % mod;
        y[i] = (y[i] + t) % mod;
      }
    }
  }
}
void NTT(long long x1[], long long x2[], int n) {
  DFT(x1, n, 1);
  DFT(x2, n, 1);
  for (int i = 0; i < n; ++i) x1[i] = mul(x1[i], x2[i]);
  DFT(x1, n, 0);
  long long vn = power(n, mod - 2);
  for (int i = 0; i < n; ++i) x1[i] = mul(x1[i], vn);
}
char str[500500];
int vis[500500];
vector<int> ve[500500];
vector<int> ans;
void solve() {
  int n, len = 1;
  scanf("%d", &n);
  nn = n;
  for (int i = 1; i <= n; i++) vis[i] = 0;
  while (len < 2 * n) len <<= 1;
  for (int i = 0; i < len; i++) x1[i] = x2[i] = 0;
  scanf("%s", str);
  for (int i = 0; i < n; i++) {
    if (str[i] == 'V') x1[i] = 1;
    if (str[i] == 'K') x2[n - 1 - i] = 1;
  }
  NTT(x1, x2, len);
  for (int i = 0; i < len; i++)
    if (x1[i]) {
      int s = abs(i - n + 1);
      for (auto i : ve[s]) vis[i] = 1;
    }
  ans.clear();
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) ans.push_back(i);
  }
  printf("%d\n", ans.size());
  for (auto i : ans) printf("%d ", i);
  puts("");
}
int main() {
  for (int i = 1; i <= 500000; i++) {
    for (int j = i; j <= 500000; j += i) {
      ve[j].push_back(i);
    }
  }
  int T;
  scanf("%d", &T);
  while (T--) solve();
  return 0;
}
