#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 20;
const double pi = acos(-1.0);
const double eps = 0.5;
struct comp {
  double r, i;
  comp(double r = 0, double i = 0) : r(r), i(i) {}
  comp operator+(comp x) { return comp(r + x.r, i + x.i); }
  comp operator-(comp x) { return comp(r - x.r, i - x.i); }
  comp operator*(comp x) { return comp(r * x.r - i * x.i, i * x.r + r * x.i); }
};
void radar(comp *a, int len) {
  int j = len >> 1;
  for (int i = 1; i < len - 1; i++) {
    if (i < j) swap(a[i], a[j]);
    int k = len >> 1;
    while (k & j) {
      j ^= k;
      k >>= 1;
    }
    j ^= k;
  }
}
void FFT(comp *a, int t, int len) {
  radar(a, len);
  for (int h = 1; h < len; h <<= 1) {
    comp wn = comp(cos(-t * pi / h), sin(-t * pi / h));
    int step = h * 2;
    for (int i = 0; i < len; i += step) {
      comp e(1, 0);
      for (int j = i; j < i + h; j++) {
        comp u = a[j], v = e * a[j + h];
        a[j] = u + v;
        a[j + h] = u - v;
        e = e * wn;
      }
    }
  }
  if (t == -1) {
    for (int i = 0; i < len; i++) a[i].r /= 1.0 * len;
  }
}
comp a[maxn], b[maxn];
bool ans[maxn];
char s[500005];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    scanf("%s", s);
    if (n == 1) {
      printf("1\n");
      printf("1\n");
      continue;
    }
    for (int i = 0; i < n; i++) {
      if (s[i] == 'V')
        a[i] = comp(1, 0);
      else if (s[i] == 'K')
        b[n - i] = comp(1, 0);
    }
    int len = 1;
    while (len < n + n) len <<= 1;
    FFT(a, 1, len);
    FFT(b, 1, len);
    for (int i = 0; i < len; i++) a[i] = a[i] * b[i];
    FFT(a, -1, len);
    for (int i = 1; i <= n; i++) {
      if (((int)(a[n + i].r + eps) == 0) && ((int)(a[n - i].r + eps) == 0)) {
        ans[i] = true;
      } else
        ans[i] = false;
    }
    vector<int> v;
    for (int i = 1; i <= n; i++) {
      for (int j = i + i; j <= n; j += i) {
        ans[i] = ans[i] & ans[j];
      }
      if (ans[i]) v.push_back(i);
    }
    printf("%d\n", (int)v.size());
    for (int i = 0, sz = (int)v.size(); i < sz; i++) printf("%d ", v[i]);
    printf("\n");
    for (int i = 0; i < len + 10; i++) a[i] = comp(0, 0), b[i] = comp(0, 0);
  }
  return 0;
}
