#include <bits/stdc++.h>
using namespace std;
using cd = complex<double>;
const double PI = acos(-1);
void fft(vector<cd> &a, bool invert) {
  int n = a.size();
  for (int i = 1, j = 0; i < n; i++) {
    int bit = n >> 1;
    for (; j & bit; bit >>= 1) j ^= bit;
    j ^= bit;
    if (i < j) swap(a[i], a[j]);
  }
  for (int len = 2; len <= n; len <<= 1) {
    double ang = 2 * PI / len * (invert ? -1 : 1);
    cd wlen(cos(ang), sin(ang));
    for (int i = 0; i < n; i += len) {
      cd w(1);
      for (int j = 0; j < len / 2; j++) {
        cd u = a[i + j], v = a[i + j + len / 2] * w;
        a[i + j] = u + v;
        a[i + j + len / 2] = u - v;
        w *= wlen;
      }
    }
  }
  if (invert) {
    for (cd &x : a) x /= n;
  }
}
vector<int> multiply(vector<int> &a, vector<int> &b) {
  vector<cd> 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, 0);
  fft(fb, 0);
  for (int i = 0; i < n; i++) fa[i] *= fb[i];
  fft(fa, 1);
  vector<int> res(n);
  for (int i = 0; i < n; i++) res[i] = round(fa[i].real());
  return res;
}
int n, t;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    vector<int> v1, v2;
    cin >> n >> s;
    v1.resize(n);
    v2.resize(n);
    for (int i = 0; i < n; i++)
      if (s[i] == 'V')
        v1[i] = 1;
      else if (s[i] == 'K')
        v2[-i + n - 1] = 1;
    vector<int> res = multiply(v1, v2);
    vector<int> ans;
    for (int i = 1; i < n; i++) {
      int good = 1;
      for (int j = i; j < n; j += i)
        if (res[j + n - 1] + res[-j + n - 1]) {
          good = 0;
          break;
        }
      if (good) ans.push_back(i);
    }
    ans.push_back(n);
    cout << ans.size() << "\n";
    for (auto i : ans) cout << i << " ";
    cout << "\n";
  }
}
