#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
struct FFT {
  int N;
  vector<int> perm;
  void precalculate() {
    perm.resize(N);
    perm[0] = 0;
    for (int k = 1; k < N; k <<= 1) {
      for (int i = 0; i < k; i++) {
        perm[i] <<= 1;
        perm[i + k] = 1 + perm[i];
      }
    }
  }
  void fft(vector<complex<double> > &v, bool invert = false) {
    if (v.size() != perm.size()) {
      N = v.size();
      assert(N && (N & (N - 1)) == 0);
      precalculate();
    }
    for (int i = 0; i < N; i++)
      if (i < perm[i]) swap(v[i], v[perm[i]]);
    for (int len = 2; len <= N; len <<= 1) {
      double angle = 2 * PI / len;
      if (invert) angle = -angle;
      complex<double> factor = polar(1.0, angle);
      for (int i = 0; i < N; i += len) {
        complex<double> w(1);
        for (int j = 0; j < len / 2; j++) {
          complex<double> x = v[i + j], y = w * v[i + j + len / 2];
          v[i + j] = x + y;
          v[i + j + len / 2] = x - y;
          w *= factor;
        }
      }
    }
    if (invert)
      for (complex<double> &x : v) x /= N;
  }
  vector<long long> multiply(vector<long long> a, vector<long long> b) {
    vector<complex<double> > fa(a.begin(), a.end()), fb(b.begin(), b.end());
    int n = 1;
    while (n < a.size() + b.size()) n <<= 1;
    fa.resize(n);
    fb.resize(n);
    fft(fa);
    fft(fb);
    for (int i = 0; i < n; i++) fa[i] *= fb[i];
    fft(fa, true);
    vector<long long> ans(n);
    for (int i = 0; i < n; i++) ans[i] = round(fa[i].real());
    return ans;
  }
};
const int N = 500000;
vector<int> dv[N + 1];
void sieve() {
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j += i) {
      dv[j].push_back(i);
    }
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  sieve();
  int t;
  cin >> t;
  FFT fft;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<bool> flg(n + 1, true);
    vector<long long> a(n, 0), b(n, 0);
    int offset = n - 1;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'V')
        a[i] = 1;
      else if (s[i] == 'K')
        b[offset - i] = 1;
    }
    vector<long long> c = fft.multiply(a, b);
    for (int i = 1; i <= n; i++) {
      if (c[i + offset]) {
        flg[i] = false;
      }
    }
    fill(a.begin(), a.end(), 0);
    fill(b.begin(), b.end(), 0);
    for (int i = 0; i < n; i++) {
      if (s[i] == 'K')
        a[i] = 1;
      else if (s[i] == 'V')
        b[offset - i] = 1;
    }
    c = fft.multiply(a, b);
    for (int i = 1; i <= n; i++) {
      if (c[i + offset]) {
        flg[i] = false;
      }
    }
    for (int i = 2; i <= n; i++) {
      if (flg[i] == false) {
        for (int d : dv[i]) {
          flg[d] = false;
        }
      }
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      cnt += flg[i];
    }
    cout << cnt << "\n";
    for (int i = 1; i <= n; i++) {
      if (flg[i]) cout << i << " ";
    }
    cout << "\n";
  }
}
