#include <bits/stdc++.h>
using namespace std;
template <class T>
bool ckmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <class T>
bool ckmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
inline int add(int x, int y) {
  return (x += y) >= 998244353 ? x - 998244353 : x;
}
inline int sub(int x, int y) {
  return (x += 998244353 - y) >= 998244353 ? x - 998244353 : x;
}
inline int qpow(int n, int k) {
  int res = 1;
  for (; k; k >>= 1, n = 1ll * n * n % 998244353)
    if (k & 1) res = 1ll * n * res % 998244353;
  return res;
}
const int N = 500005;
int rt[N << 2], rev[N << 2];
int lim, lg;
inline void initpoly(const int &n = (N - 5) << 1) {
  for (lim = 1, lg = 0; lim < n; lim <<= 1, ++lg)
    ;
  for (int i = 1; i < lim; i <<= 1) {
    rt[i] = 1;
    int w = qpow(3, (998244353 - 1) / (i << 1));
    for (int j = 1; j < i; ++j) rt[i + j] = 1ll * rt[i + j - 1] * w % 998244353;
  }
}
inline void initrev(const int &n) {
  for (lim = 1, lg = 0; lim < n; lim <<= 1, ++lg)
    ;
  for (int i = 0; i < lim; ++i)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (lg - 1));
}
inline void NTT(vector<int> &a, int op) {
  a.resize(lim);
  if (!op) reverse(a.begin() + 1, a.end());
  for (int i = 0; i < lim; ++i)
    if (i > rev[i]) swap(a[i], a[rev[i]]);
  for (int i = 1; i < lim; i <<= 1) {
    for (int j = 0; j < lim; j += i << 1) {
      for (int k = 0; k < i; ++k) {
        int X = a[j + k], Y = 1ll * rt[i + k] * a[i + j + k] % 998244353;
        a[j + k] = (X + Y) % 998244353,
              a[i + j + k] = (X + 998244353 - Y) % 998244353;
      }
    }
  }
  if (!op) {
    for (int i = 0, j = qpow(lim, 998244353 - 2); i < lim; ++i)
      a[i] = 1ll * a[i] * j % 998244353;
  }
}
vector<int> operator*(vector<int> a, vector<int> b) {
  int n = a.size(), m = b.size();
  if (n < 64 || m < 64) {
    vector<int> res(n + m - 1, 0);
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j)
        res[i + j] = (res[i + j] + 1ll * a[i] * b[j]) % 998244353;
    return res;
  }
  initrev(n + m - 1), NTT(a, 1), NTT(b, 1);
  for (int i = 0; i < lim; ++i) a[i] = 1ll * a[i] * b[i] % 998244353;
  NTT(a, 0), a.resize(n + m - 1);
  return a;
}
int n, s[N], ans[N], tot;
char str[N];
bool vis[N];
void Main() {
  scanf("%d%s", &n, str), n = strlen(str), tot = 0;
  for (int i = 1; i <= n; ++i) vis[i] = 0;
  for (int i = 0; i < n; ++i) {
    if (str[i] == '?')
      s[i] = 0;
    else if (str[i] == 'V')
      s[i] = 1;
    else
      s[i] = 2;
  }
  vector<int> a(n), b(n), c;
  for (int i = 0; i < n; ++i) a[i] = s[i] == 1;
  for (int i = 0; i < n; ++i) b[i] = s[i] == 2;
  reverse(a.begin(), a.end());
  c = a * b;
  for (int i = 1; i <= n; ++i) vis[i] = 1;
  for (int i = 0; i < (int)(c).size(); ++i)
    if (c[i]) vis[abs(i - n + 1)] = 0;
  for (int i = 1; i <= n; ++i) {
    if (vis[i]) {
      bool flg = 1;
      for (int j = i; j <= n; j += i)
        if (!vis[j]) {
          flg = 0;
          break;
        }
      if (!flg) vis[i] = 0;
    }
  }
  for (int i = 1; i <= n; ++i)
    if (vis[i]) ans[++tot] = i;
  printf("%d\n", tot);
  for (int i = 1; i <= tot; ++i) printf("%d%c", ans[i], " \n"[i == tot]);
}
signed main() {
  initpoly();
  for (int T = read(); T; --T) Main();
}
