#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
struct Complex {
  double real, imag;
  Complex(double a = 0, double b = 0) : real(a), imag(b) {}
  Complex operator+(Complex p) { return Complex(real + p.real, imag + p.imag); }
  Complex operator-(Complex p) { return Complex(real - p.real, imag - p.imag); }
  Complex operator*(Complex p) {
    return Complex(real * p.real - imag * p.imag,
                   real * p.imag + imag * p.real);
  }
  Complex operator*(double p) { return Complex(real * p, imag * p); }
  Complex operator/(double p) { return Complex(real / p, imag / p); }
  Complex conj() { return Complex(real, -imag); }
};
ostream &operator<<(ostream &os, const Complex &p) {
  return os << "(" << p.real << ", " << p.imag << ")";
}
const int ms = 1 << 20;
char buff[ms];
int a[ms], b[ms];
Complex aux[ms];
void fft(Complex p[], int n, int oper) {
  for (int i = 1, j = 0; i < n - 1; ++i) {
    for (int s = n; j ^= s >>= 1, ~j & s;)
      ;
    if (i < j) swap(p[i], p[j]);
  }
  Complex wn, w;
  for (int d = 0; (1 << d) < n; ++d) {
    int m = 1 << d, m2 = m << 1;
    double p0 = pi / m * oper;
    wn = Complex(cos(p0), sin(p0));
    for (int i = 0; i < n; i += m2) {
      w = 1;
      for (int j = 0; j < m; ++j) {
        Complex &p1 = p[i + j + m], &p2 = p[i + j];
        Complex t = w * p1;
        p1 = p2 - t;
        p2 = p2 + t;
        w = w * wn;
      }
    }
  }
  if (oper == -1)
    for (int i = 0; i < n; ++i) p[i] = p[i] / n;
}
void mult(int a[], int &n, int b[], int m) {
  int N = 1;
  while (N < n + m) N <<= 1;
  for (int i = 0; i < N; ++i) {
    aux[i].real = i < n ? a[i] : 0;
    aux[i].imag = i < m ? b[i] : 0;
  }
  fft(aux, N, 1);
  for (int i = 0; i <= (N >> 1); ++i) {
    int j = (N - i) & (N - 1);
    aux[i] = (aux[i] * aux[i] - (aux[j] * aux[j]).conj()) * Complex(0, -0.25);
    aux[j] = aux[i].conj();
  }
  fft(aux, N, -1);
  for (int i = 0; i < N; ++i) {
  }
  n += m - 1;
  for (int i = 0; i < n; ++i) {
    a[i] = aux[i].real + 0.5;
  }
}
int read() {
  int x = 0;
  int c = getchar();
  for (; !isdigit(c); c = getchar()) {
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  return x;
}
void write(int x) {
  if (x / 10) {
    write(x / 10);
  }
  putchar(x % 10 + '0');
}
int main() {
  cerr << fixed << setprecision(0);
  int t = read();
  while (t--) {
    int n = read();
    scanf(" %s", buff);
    string str(buff);
    for (int i = 0; i < n; ++i) {
      a[i] = str[i] == 'V';
      b[n - i - 1] = str[i] == 'K';
    }
    int N = n;
    mult(a, N, b, n);
    vector<int> ans;
    for (int d = 1; d <= n; ++d) {
      bool ok = true;
      for (int i = (n % d - 1 + d) % d; i < N; i += d) {
        ok &= a[i] == 0;
      }
      if (ok) {
        ans.push_back(d);
      }
    }
    write(ans.size());
    putchar('\n');
    for (int d : ans) {
      write(d);
      putchar(' ');
    }
    putchar('\n');
  }
  return 0;
}
