#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const double PI = acos(-1.);
const double eps = 1e-10;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 262144 * 8 + 5;
char s[MAXN];
char t[MAXN];
struct CP {
  double x, y;
  CP() {}
  CP(double x, double y) : x(x), y(y) {}
  inline double real() { return x; }
  inline CP operator*(const CP& r) const {
    return CP(x * r.x - y * r.y, x * r.y + y * r.x);
  }
  inline CP operator-(const CP& r) const { return CP(x - r.x, y - r.y); }
  inline CP operator+(const CP& r) const { return CP(x + r.x, y + r.y); }
  inline CP conj(const CP& r) { return CP(r.x, -r.y); }
};
CP a[MAXN], b[MAXN];
int r[MAXN], res[MAXN];
void fft_init(int nm, int k) {
  for (int i = 0; i < nm; ++i) r[i] = (r[i >> 1] >> 1) | ((i & 1) << (k - 1));
}
void fft(CP ax[], int nm, int op) {
  for (int i = 0; i < nm; ++i)
    if (i < r[i]) swap(ax[i], ax[r[i]]);
  for (int h = 2, m = 1; h <= nm; h <<= 1, m <<= 1) {
    CP wn = CP(cos(op * 2 * PI / h), sin(op * 2 * PI / h));
    for (int i = 0; i < nm; i += h) {
      CP w(1, 0);
      for (int j = i; j < i + m; ++j, w = w * wn) {
        CP t = w * ax[j + m];
        ax[j + m] = ax[j] - t;
        ax[j] = ax[j] + t;
      }
    }
  }
  if (op == -1)
    for (int i = 0; i < nm; ++i) ax[i].x /= nm;
}
void trans(int ax[], int bx[], int n, int m, int mul) {
  int nm = 1, k = 0;
  while (nm < 2 * n || nm < 2 * m) nm <<= 1, ++k;
  for (int i = 0; i < n; ++i) a[i] = CP(ax[i], 0);
  for (int i = 0; i < m; ++i) b[i] = CP(bx[i], 0);
  for (int i = n; i < nm; ++i) a[i] = CP(0, 0);
  for (int i = m; i < nm; ++i) b[i] = CP(0, 0);
  fft_init(nm, k);
  fft(a, nm, 1);
  fft(b, nm, 1);
  for (int i = 0; i < nm; ++i) a[i] = a[i] * b[i];
  fft(a, nm, -1);
  nm = n + m - 1;
  for (int i = 0; i < nm; ++i) res[i] += (int)(a[i].real() + 0.5) * mul;
}
int s1[MAXN], t1[MAXN];
int ans[MAXN];
int getid(char x) {
  if (x == 'V') return 1;
  if (x == 'K') return -1;
  return 0;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    scanf("%d %s", &n, s);
    for (int i = 0; i <= 2 * n; i++) res[i] = 0;
    for (int i = 0; i < n; i++) {
      s1[i] = getid(s[i]) * getid(s[i]) * getid(s[i]);
      t1[i] = getid(s[i]);
    }
    reverse(t1, t1 + n);
    trans(s1, t1, n, n, 1);
    for (int i = 0; i < n; i++) {
      s1[i] = getid(s[i]);
      t1[i] = getid(s[i]) * getid(s[i]) * getid(s[i]);
    }
    reverse(t1, t1 + n);
    trans(s1, t1, n, n, 1);
    for (int i = 0; i < n; i++) {
      s1[i] = getid(s[i]) * getid(s[i]);
      t1[i] = getid(s[i]) * getid(s[i]);
    }
    reverse(t1, t1 + n);
    trans(s1, t1, n, n, -2);
    for (int i = 0; i <= n; i++) ans[i] = 0;
    for (int i = 0; i < n; i++)
      if (res[i] == 0) ans[n - i - 1] = 1;
    ans[n] = 1;
    vector<int> v;
    for (int i = n; i >= 1; i--) {
      for (int j = i + i; j <= n; j += i) ans[i] &= ans[j];
      if (ans[i]) v.push_back(i);
    }
    printf("%d\n", v.size());
    reverse(v.begin(), v.end());
    for (int i : v) printf("%d ", i);
    puts("");
  }
  return 0;
}
