#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
struct pdd {
  double first, second;
  pdd() : first(0), second(0) {}
  pdd(double _x, double _y) : first(_x), second(_y) {}
};
inline pdd operator+(const pdd &a, const pdd &b) {
  return pdd(a.first + b.first, a.second + b.second);
}
inline pdd operator-(const pdd &a, const pdd &b) {
  return pdd(a.first - b.first, a.second - b.second);
}
inline pdd operator*(const pdd &a, const pdd &b) {
  return pdd(a.first * b.first - a.second * b.second,
             a.first * b.second + a.second * b.first);
}
inline pdd operator/(const pdd &a, const double &b) {
  return pdd(a.first / b, a.second / b);
}
inline pdd conj(const pdd &a) { return pdd(a.first, -a.second); }
int rv[1 << 21];
pdd w[1 << 21];
pdd tmp[1 << 20];
void fft(pdd *a, int n, bool inv) {
  static int SN = -1;
  int cc = 0;
  for (int _n((30) - 1), i(0); i <= _n; i++) {
    if (n & 1 << i) cc = i;
  }
  if (cc != SN) {
    SN = cc;
    rv[0] = 0;
    rv[1] = 1;
    for (int _n((SN - 1)), st(1); st <= _n; st++) {
      int k = 1 << st;
      for (int _n((k)-1), i(0); i <= _n; i++) {
        rv[i + k] = rv[i] * 2 + 1;
        rv[i] *= 2;
      }
    }
    for (int _n((1 << SN) - 1), i(0); i <= _n; i++) {
      w[i] = pdd(cos(2.0 * 3.1415926535897932384626433832795028841971 * i / n),
                 sin(2.0 * 3.1415926535897932384626433832795028841971 * i / n));
    }
  }
  for (int _n((n)-1), i(0); i <= _n; i++) {
    if (rv[i] <= i) swap(a[i], a[rv[i]]);
  }
  for (int st = 2; st <= n; st *= 2) {
    int d = n / st, o = st / 2;
    for (int j = 0; j < o; ++j) {
      tmp[j] = inv ? conj(w[j * d]) : w[j * d];
    }
    for (int i = 0; i < n; i += st) {
      for (int j = 0; j < o; ++j) {
        pdd u = a[i + j], v = a[i + j + o] * tmp[j];
        a[i + j] = u + v;
        a[i + j + o] = u - v;
      }
    }
  }
  if (inv) {
    for (int _n((n)-1), i(0); i <= _n; i++) a[i] = a[i] / n;
  }
}
void fft_unpack(pdd *z, pdd *first, pdd *second, int n) {
  for (int i = 1; i < n; ++i) {
    first[i] = (z[i] + conj(z[n - i])) / 2;
    second[i] = (z[i] - conj(z[n - i])) / 2;
    swap(second[i].first, second[i].second);
    second[i].second = -second[i].second;
  }
  first[0] = (z[0] + conj(z[0])) / 2;
  second[0] = (z[0] - conj(z[0])) / 2;
  swap(second[0].first, second[0].second);
  second[0].second = -second[0].second;
}
void fft_pack(pdd *first, pdd *second, pdd *z, int n) {
  for (int i = 1; i < n; ++i) {
    z[i] = first[i] + second[i] * pdd(0, 1);
    z[n - i] = conj(first[i] - second[i] * pdd(0, 1));
  }
  z[0].first = first[0].first;
  z[0].second = second[0].first;
}
int a, b, c, d, n, m, k, kolt;
char str[500002];
bool ans[500002];
pdd A[1 << 21], B[1 << 21], C[1 << 21];
int pr[1 << 21];
void check() {
  int t = 1;
  while (t < 2 * n) t *= 2;
  for (int _n((t * 2) - 1), i(0); i <= _n; i++)
    A[i] = pdd(0, 0), B[i] = pdd(0, 0), C[i] = pdd(0, 0);
  for (int _n((n)-1), i(0); i <= _n; i++) {
    if (str[i] == 'V') {
      C[i].first = 1;
      C[i + n].first = 0;
    } else if (str[i] == 'K') {
      C[n - i - 1].second = 1;
      C[2 * n - i - 1].second = 1;
    }
  }
  fft(C, t * 2, 0);
  fft_unpack(C, A, B, t * 2);
  for (int _n((2 * t) - 1), i(0); i <= _n; i++) {
    C[i] = A[i] * B[i];
  }
  fft(C, t * 2, 1);
  for (int _n((t * 2) - 1), i(0); i <= _n; i++) {
    pr[i] = (int)(C[i].first + 0.5);
  }
  for (int _n((n - 1)), len(1); len <= _n; len++) {
    if (!ans[len]) continue;
    bool ok = 1;
    for (int i = 0; i < n; i += len) {
      if (pr[2 * n - 1 + i]) {
        ok = 0;
        break;
      }
    }
    if (!ok) {
      ans[len] = 0;
    }
  }
}
int main() {
  scanf("%d", &kolt);
  for (int _n((kolt)), hod(1); hod <= _n; hod++) {
    scanf("%d", &n);
    scanf("%s", str);
    for (int _n((n)), i(1); i <= _n; i++) ans[i] = 1;
    check();
    for (int _n((n)-1), i(0); i <= _n; i++)
      if (str[i] == 'V')
        str[i] = 'K';
      else if (str[i] == 'K')
        str[i] = 'V';
    check();
    int cnt = 0;
    for (int _n((n)), i(1); i <= _n; i++)
      if (ans[i]) ++cnt;
    printf("%d\n", cnt);
    bool was = 0;
    for (int _n((n)), i(1); i <= _n; i++) {
      if (!ans[i]) continue;
      if (was)
        printf(" ");
      else
        was = 1;
      printf("%d", i);
    }
    printf("\n");
  }
}
