#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<double> base;

const double TWO_PI = 2 * acos(-1.0);
base w[530000];
int bit[53000];

void init_fft(int n) {

}

void fft(vector<base>& a, bool invert) {
    int n = (int)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 angle = TWO_PI / len;
        if (invert)
            angle = -angle;
        base wlen(cos(angle), sin(angle));
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < (len >> 1); ++j) {
                base u = a[i + j];
                base v = a[i + j + (len >> 1)] * w[j];
                a[i + j] = u + v;
                a[i + j + (len >> 1)] = u - v;
            }
        }
    }

    if (invert)
        for (int i = 0; i < n; ++i)
            a[i] /= n;
}

vector<int> multiply(const vector<int>& a, const vector<int>& b) {
    vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());

    size_t max_size = max(a.size(), b.size());
    size_t n = 1;
    while (n < max_size)
        n <<= 1;
    n <<= 1;

    fa.resize(n);
    fb.resize(n);
    init_fft(n);
    fft(fa, false);
    fft(fb, false);
    for (size_t i = 0; i < n; ++i)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<int> res(n);
    for (size_t i = 0; i < n; ++i)
        res[i] = (int)round(fa[i].real());
    return res;
}

int main()
{
    int t;
    cin >> t;
    while (t--) {
        int n;
        string s;
        cin >> n >> s;
        vector<int> va(n + 1), vb(n + 1);
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'V')
                va[i] = 1;
            else if (s[i] == 'K')
                vb[n - i] = 1;
        }
        vector<int> periods(n + 1), ans;
        vector<int> v = multiply(va, vb);
        for (int i = 1; i < 2 * n; ++i)
            if (v[i])
                periods[abs(n - i)] = 1;
        for (int i = 1; i <= n; ++i) {
            bool good = true;
            for (int j = i; j <= n; j += i) {
                if (periods[j]) {
                    good = false;
                    break;
                }
            }
            if (good)
                ans.push_back(i);
        }

        cout << ans.size() << "\n";
        for (int x : ans)
            cout << x << " ";
        cout << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<double> base;

const double TWO_PI = 2 * acos(-1.0);
double wlen_pow[524300];

void fft(vector<base>& a, bool invert) {
    int n = (int)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 angle = TWO_PI / len;
        if (invert)
            angle = -angle;
        base wlen(cos(angle), sin(angle));
        wlen_pow[0] = base(1);
        for (int i = 1; i < (n >> 1); ++i)
            wlen_pow[i] = wlen_pow[i - 1] * wlen;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < (len >> 1); ++j) {
                base u = a[i + j];
                base v = a[i + j + (len >> 1)] * wlen_pow[j];
                a[i + j] = u + v;
                a[i + j + (len >> 1)] = u - v;
            }
        }
    }

    if (invert)
        for (int i = 0; i < n; ++i)
            a[i] /= n;
}

vector<int> multiply(const vector<int>& a, const vector<int>& b) {
    vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());

    size_t max_size = max(a.size(), b.size());
    size_t n = 1;
    while (n < max_size)
        n <<= 1;
    n <<= 1;

    fa.resize(n);
    fb.resize(n);
    fft(fa, false);
    fft(fb, false);
    for (size_t i = 0; i < n; ++i)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<int> res(n);
    for (size_t i = 0; i < n; ++i)
        res[i] = (int)round(fa[i].real());
    return res;
}

int main()
{
    int t;
    cin >> t;
    while (t--) {
        int n;
        string s;
        cin >> n >> s;
        vector<int> va(n + 1), vb(n + 1);
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'V')
                va[i] = 1;
            else if (s[i] == 'K')
                vb[n - i] = 1;
        }
        vector<int> periods(n + 1), ans;
        vector<int> v = multiply(va, vb);
        for (int i = 1; i < 2 * n; ++i)
            if (v[i])
                periods[abs(n - i)] = 1;
        for (int i = 1; i <= n; ++i) {
            bool good = true;
            for (int j = i; j <= n; j += i) {
                if (periods[j]) {
                    good = false;
                    break;
                }
            }
            if (good)
                ans.push_back(i);
        }

        cout << ans.size() << "\n";
        for (int x : ans)
            cout << x << " ";
        cout << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<double> base;

const ld PI = acos(ld(-1));

void fft(vector<base>& a, bool invert) {
    int n = (int)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 angle = 2 * PI / len;
        if (invert)
            angle = -angle;
        base wlen(cos(angle), sin(angle));
        for (int i = 0; i < n; i += len) {
            base w(1);
            for (int j = 0; j < (len >> 1); ++j) {
                base u = a[i + j];
                base v = a[i + j + (len >> 1)] * w;
                a[i + j] = u + v;
                a[i + j + (len >> 1)] = u - v;
                w *= wlen;
            }
        }
    }

    if (invert)
        for (int i = 0; i < n; ++i)
            a[i] /= n;
}

vector<int> multiply(const vector<int>& a, const vector<int>& b) {
    vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());

    size_t max_size = max(a.size(), b.size());
    size_t n = 1;
    while (n < max_size)
        n <<= 1;
    n <<= 1;

    fa.resize(n);
    fb.resize(n);
    fft(fa, false);
    fft(fb, false);
    for (size_t i = 0; i < n; ++i)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<int> res(n);
    for (size_t i = 0; i < n; ++i)
        res[i] = (int)round(fa[i].real());
    return res;
}

int main()
{
    int t;
    cin >> t;
    while (t--) {
        int n;
        string s;
        cin >> n >> s;
        vector<int> va(n + 1), vb(n + 1);
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'V')
                va[i] = 1;
            else if (s[i] == 'K')
                vb[n - i] = 1;
        }
        vector<int> periods(n + 1), ans;
        vector<int> v = multiply(va, vb);
        for (int i = 1; i < 2 * n; ++i)
            if (v[i])
                periods[abs(n - i)] = 1;
        for (int i = 1; i <= n; ++i) {
            bool good = true;
            for (int j = i; j <= n; j += i) {
                if (periods[j]) {
                    good = false;
                    break;
                }
            }
            if (good)
                ans.push_back(i);
        }

        cout << ans.size() << "\n";
        for (int x : ans)
            cout << x << " ";
        cout << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<double> base;

const double PI = acos(-1.0);
base wlen_pow[524300];

void fft(vector<base>& a, bool invert) {
    int n = (int)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 = 1; len < n; len <<= 1) {
        double angle = PI / len;
        if (invert)
            angle = -angle;
        base wlen(cos(angle), sin(angle));
        wlen_pow[0] = base(1);
        for (int i = 1; i < (n >> 1); ++i)
            wlen_pow[i] = wlen_pow[i - 1] * wlen;
        for (int i = 0; i < n; i += len << 1) {
            for (int j = 0; j < len; ++j) {
                base u = a[i + j];
                base v = a[i + j + len] * wlen_pow[j];
                a[i + j] = u + v;
                a[i + j + len] = u - v;
            }
        }
    }

    if (invert)
        for (int i = 0; i < n; ++i)
            a[i] /= n;
}

void multiply(const vector<int>& a, const vector<int>& b, vector<int>& res) {
    size_t max_size = max(a.size(), b.size());
    size_t n = 1;
    while (n < max_size)
        n <<= 1;
    n <<= 1;

    vector<base> fa(n), fb(n);
    for (size_t i = a.size(); i--; )
        fa[i] = a[i];
    for (size_t i = b.size(); i--; )
        fb[i] = b[i];
    fft(fa, false);
    fft(fb, false);
    for (size_t i = 0; i < n; ++i)
        fa[i] *= fb[i];
    fft(fa, true);

    res.resize(n);
    for (size_t i = 0; i < n; ++i)
        res[i] = (int)round(fa[i].real());
}

int main()
{
    int t;
    cin >> t;
    while (t--) {
        int n;
        string s;
        cin >> n >> s;
        vector<int> va(n + 1), vb(n + 1);
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'V')
                va[i] = 1;
            else if (s[i] == 'K')
                vb[n - i] = 1;
        }
        vector<int> periods(n + 1), ans;
        multiply(va, vb, va);
        for (int i = 1; i < 2 * n; ++i)
            if (va[i])
                periods[abs(n - i)] = 1;
        for (int i = 1; i <= n; ++i) {
            bool good = true;
            for (int j = i; j <= n; j += i) {
                if (periods[j]) {
                    good = false;
                    break;
                }
            }
            if (good)
                ans.push_back(i);
        }

        cout << ans.size() << "\n";
        for (int x : ans)
            cout << x << " ";
        cout << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<double> base;

const double TWO_PI = 2 * acos(-1.0);
base wlen_pow[524300];

void fft(vector<base>& a, bool invert) {
    int n = (int)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 angle = TWO_PI / len;
        if (invert)
            angle = -angle;
        base wlen(cos(angle), sin(angle));
        wlen_pow[0] = base(1);
        for (int i = 1; i < (n >> 1); ++i)
            wlen_pow[i] = wlen_pow[i - 1] * wlen;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < (len >> 1); ++j) {
                base u = a[i + j];
                base v = a[i + j + (len >> 1)] * wlen_pow[j];
                a[i + j] = u + v;
                a[i + j + (len >> 1)] = u - v;
            }
        }
    }

    if (invert)
        for (int i = 0; i < n; ++i)
            a[i] /= n;
}

void multiply(const vector<int>& a, const vector<int>& b, vector<int>& res) {
    size_t max_size = max(a.size(), b.size());
    size_t n = 1;
    while (n < max_size)
        n <<= 1;
    n <<= 1;

    vector<base> fa(n), fb(n);
    for (size_t i = a.size(); i--; )
        fa[i] = a[i];
    for (size_t i = b.size(); i--; )
        fb[i] = b[i];
    fft(fa, false);
    fft(fb, false);
    for (size_t i = 0; i < n; ++i)
        fa[i] *= fb[i];
    fft(fa, true);

    res.resize(n);
    for (size_t i = 0; i < n; ++i)
        res[i] = (int)round(fa[i].real());
}

int main()
{
    int t;
    cin >> t;
    while (t--) {
        int n;
        string s;
        cin >> n >> s;
        vector<int> va(n + 1), vb(n + 1);
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'V')
                va[i] = 1;
            else if (s[i] == 'K')
                vb[n - i] = 1;
        }
        vector<int> periods(n + 1), ans;
        vector<int> v = multiply(va, vb);
        for (int i = 1; i < 2 * n; ++i)
            if (v[i])
                periods[abs(n - i)] = 1;
        for (int i = 1; i <= n; ++i) {
            bool good = true;
            for (int j = i; j <= n; j += i) {
                if (periods[j]) {
                    good = false;
                    break;
                }
            }
            if (good)
                ans.push_back(i);
        }

        cout << ans.size() << "\n";
        for (int x : ans)
            cout << x << " ";
        cout << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<double> base;

const double TWO_PI = 2 * acos(-1.0);
base wlen_pow[524300];

void fft(vector<base>& a, bool invert) {
    int n = (int)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 angle = TWO_PI / len;
        if (invert)
            angle = -angle;
        base wlen(cos(angle), sin(angle));
        wlen_pow[0] = base(1);
        for (int i = 1; i < (n >> 1); ++i)
            wlen_pow[i] = wlen_pow[i - 1] * wlen;
        for (int i = 0; i < n; i += len) {
            for (int j = 0; j < (len >> 1); ++j) {
                base u = a[i + j];
                base v = a[i + j + (len >> 1)] * wlen_pow[j];
                a[i + j] = u + v;
                a[i + j + (len >> 1)] = u - v;
            }
        }
    }

    if (invert)
        for (int i = 0; i < n; ++i)
            a[i] /= n;
}

vector<int> multiply(const vector<int>& a, const vector<int>& b) {
    vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());

    size_t max_size = max(a.size(), b.size());
    size_t n = 1;
    while (n < max_size)
        n <<= 1;
    n <<= 1;

    fa.resize(n);
    fb.resize(n);
    fft(fa, false);
    fft(fb, false);
    for (size_t i = 0; i < n; ++i)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<int> res(n);
    for (size_t i = 0; i < n; ++i)
        res[i] = (int)round(fa[i].real());
    return res;
}

int main()
{
    int t;
    cin >> t;
    while (t--) {
        int n;
        string s;
        cin >> n >> s;
        vector<int> va(n + 1), vb(n + 1);
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'V')
                va[i] = 1;
            else if (s[i] == 'K')
                vb[n - i] = 1;
        }
        vector<int> periods(n + 1), ans;
        vector<int> v = multiply(va, vb);
        for (int i = 1; i < 2 * n; ++i)
            if (v[i])
                periods[abs(n - i)] = 1;
        for (int i = 1; i <= n; ++i) {
            bool good = true;
            for (int j = i; j <= n; j += i) {
                if (periods[j]) {
                    good = false;
                    break;
                }
            }
            if (good)
                ans.push_back(i);
        }

        cout << ans.size() << "\n";
        for (int x : ans)
            cout << x << " ";
        cout << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<double> base;

const double TWO_PI = 2 * acos(-1.0);

void fft(vector<base>& a, bool invert) {
    int n = (int)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 angle = TWO_PI / len;
        if (invert)
            angle = -angle;
        base wlen(cos(angle), sin(angle));
        for (int i = 0; i < n; i += len) {
            base w(1);
            for (int j = 0; j < (len >> 1); ++j) {
                base u = a[i + j];
                base v = a[i + j + (len >> 1)] * w;
                a[i + j] = u + v;
                a[i + j + (len >> 1)] = u - v;
                w *= wlen;
            }
        }
    }

    if (invert)
        for (int i = 0; i < n; ++i)
            a[i] /= n;
}

vector<int> multiply(const vector<int>& a, const vector<int>& b) {
    vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());

    size_t max_size = max(a.size(), b.size());
    size_t n = 1;
    while (n < max_size)
        n <<= 1;
    n <<= 1;

    fa.resize(n);
    fb.resize(n);
    fft(fa, false);
    fft(fb, false);
    for (size_t i = 0; i < n; ++i)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<int> res(n);
    for (size_t i = 0; i < n; ++i)
        res[i] = (int)round(fa[i].real());
    return res;
}

int main()
{
    int t;
    cin >> t;
    while (t--) {
        int n;
        string s;
        cin >> n >> s;
        vector<int> va(n + 1), vb(n + 1);
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'V')
                va[i] = 1;
            else if (s[i] == 'K')
                vb[n - i] = 1;
        }
        vector<int> periods(n + 1), ans;
        vector<int> v = multiply(va, vb);
        for (int i = 1; i < 2 * n; ++i)
            if (v[i])
                periods[abs(n - i)] = 1;
        for (int i = 1; i <= n; ++i) {
            bool good = true;
            for (int j = i; j <= n; j += i) {
                if (periods[j]) {
                    good = false;
                    break;
                }
            }
            if (good)
                ans.push_back(i);
        }

        cout << ans.size() << "\n";
        for (int x : ans)
            cout << x << " ";
        cout << "\n";
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef complex<double> cd;
double PI = 4 * atan(1.);

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int LOG = 20;
const int N = 1 << LOG;
const int NN = N + 5;
cd w[NN];
int rev[NN];

void initFFT()
{
    for (int i = 0; i < N; i++)
        w[i] = cd(cos(2 * PI * i / N), sin(2 * PI * i / N));
    rev[0] = 0;
    for (int mask = 1; mask < N; mask++) {
        int k = 0;
        while(((mask >> k) & 1) == 0) k++;
        rev[mask] = rev[mask ^ (1 << k)] ^ (1 << (LOG - 1 - k));
    }
}

cd F[2][NN];
void FFT(cd* A, int k)
{
    int L = 1 << k;
    for (int mask = 0; mask < L; mask++)
        F[0][rev[mask] >> (LOG - k)] = A[mask];
    int t = 0, nt = 1;
    for (int lvl = 0; lvl < k; lvl++) {
        int len = 1 << lvl;
        for (int st = 0; st < L; st += (len << 1))
            for (int i = 0; i < len; i++) {
                cd ad = F[t][st + len + i] * w[i << (LOG - 1 - lvl)];
                F[nt][st + i] = F[t][st + i] + ad;
                F[nt][st + len + i] = F[t][st + i] - ad;
            }
        swap(t, nt);
    }
    for (int i = 0; i < L; i++)
        A[i] = F[t][i];
    return;
}

cd A[NN], B[NN];
char s[NN];
int a[NN];
int ans[NN];
int n;

void solve()
{
    scanf("%d %s", &n, s);
    int k = 0;
    while((1 << k) < (2 * n)) k++;
    if (k > 5) {
        int L = 1 << k;
        for (int i = 0; i < L; i++)
            A[i] = B[i] = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'V')
                A[i] = 1;
            else if (s[i] == 'K')
                B[n - i] = 1;
        }
        FFT(A, k);
        FFT(B, k);
        for (int i = 0; i < L; i++)
            A[i] *= B[i];
        FFT(A, k);
        for (int i = 0; i < L; i++)
            a[i] = (int)(A[i].real() + 0.5);
        reverse(a + 1, a + L);
        for (int d = 1; d <= n; d++)
            ans[d] = 1;
        for (int d = 1; d <= n; d++)
            if (a[n - d] + a[n + d] > 0)
                ans[d] = 0;
    } else {
        for (int d = 1; d <= n; d++) {
            ans[d] = 1;
            for (int i = 0; i + d < n; i++) {
                if (s[i] != s[i + d] && s[i] != '?' && s[i + d] != '?')
                    ans[d] = 0;
            }
        }
    }
    int cnt = 0;
    for (int x = 1; x <= n; x++) {
        for (int y = x + x; y <= n; y += x)
            ans[x] &= ans[y];
        cnt += ans[x];
    }
    printf("%d\n", cnt);
    for (int i = 1; i <= n; i++)
        if (ans[i])
            printf("%d ", i);
    printf("\n");
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    initFFT();

    int t;
    scanf("%d", &t);
    while(t--) solve();

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef complex<double> cd;
double PI = 4 * atan(1.);

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int LOG = 20;
const int N = 1 << LOG;
const int NN = N + 5;
cd w[NN];
int rev[NN];

void initFFT()
{
    for (int i = 0; i < N; i++)
        w[i] = cd(cos(2 * PI * i / N), sin(2 * PI * i / N));
    rev[0] = 0;
    for (int mask = 1; mask < N; mask++) {
        int k = 0;
        while(((mask >> k) & 1) == 0) k++;
        rev[mask] = rev[mask ^ (1 << k)] ^ (1 << (LOG - 1 - k));
    }
}

cd F[2][NN];
void FFT(cd* A, int k)
{
    int L = 1 << k;
    for (int mask = 0; mask < L; mask++)
        F[0][rev[mask] >> (LOG - k)] = A[mask];
    int t = 0, nt = 1;
    for (int lvl = 0; lvl < k; lvl++) {
        int len = 1 << lvl;
        for (int st = 0; st < L; st += (len << 1))
            for (int i = 0; i < len; i++) {
                cd ad = F[t][st + len + i] * w[i << (LOG - 1 - lvl)];
                F[nt][st + i] = F[t][st + i] + ad;
                F[nt][st + len + i] = F[t][st + i] - ad;
            }
        swap(t, nt);
    }
    for (int i = 0; i < L; i++)
        A[i] = F[t][i];
    return;
}

cd A[NN], B[NN];
char s[NN];
int a[NN];
int ans[NN];
int n;

void solve()
{
    scanf("%d %s", &n, s);
    int k = 0;
    while((1 << k) < (2 * n + 3)) k++;
    if (k > 5) {
        int L = 1 << k;
        for (int i = 0; i < L; i++)
            A[i] = B[i] = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'V')
                A[i] = 1;
            else if (s[i] == 'K')
                B[n - i] = 1;
        }
        FFT(A, k);
        FFT(B, k);
        for (int i = 0; i < L; i++)
            A[i] *= B[i];
        FFT(A, k);
        for (int i = 0; i < L; i++)
            a[i] = (int)(A[i].real() + 0.5);
        reverse(a + 1, a + L);
        for (int d = 1; d <= n; d++)
            ans[d] = 1;
        for (int d = 1; d < n; d++)
            if (a[n - d] + a[n + d] > 0)
                ans[d] = 0;
    } else {
        for (int d = 1; d <= n; d++) {
            ans[d] = 1;
            for (int i = 0; i + d < n; i++) {
                if (s[i] != s[i + d] && s[i] != '?' && s[i + d] != '?')
                    ans[d] = 0;
            }
        }
    }
    int cnt = 0;
    for (int x = 1; x <= n; x++) {
        for (int y = x + x; y <= n; y += x)
            ans[x] &= ans[y];
        cnt += ans[x];
    }
    printf("%d\n", cnt);
    for (int i = 1; i <= n; i++)
        if (ans[i])
            printf("%d ", i);
    printf("\n");
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    initFFT();

    int t;
    scanf("%d", &t);
    while(t--) solve();

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef complex<float> cd;
double PI = 4 * atan(1);

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int LOG = 20;
const int N = 1 << LOG;
const int NN = N + 5;
cd w[NN];
int rev[NN];

void initFFT()
{
    for (int i = 0; i < N; i++)
        w[i] = cd(cos(2 * PI * i / N), sin(2 * PI * i / N));
    rev[0] = 0;
    for (int mask = 1; mask < N; mask++) {
        int k = 0;
        while(((mask >> k) & 1) == 0) k++;
        rev[mask] = rev[mask ^ (1 << k)] ^ (1 << (LOG - 1 - k));
    }
}

cd F[2][NN];
void FFT(cd* A, int k)
{
    int L = 1 << k;
    for (int mask = 0; mask < L; mask++)
        F[0][rev[mask] >> (LOG - k)] = A[mask];
    int t = 0, nt = 1;
    for (int lvl = 0; lvl < k; lvl++) {
        int len = 1 << lvl;
        for (int st = 0; st < L; st += (len << 1))
            for (int i = 0; i < len; i++) {
                cd ad = F[t][st + len + i] * w[i << (LOG - 1 - lvl)];
                F[nt][st + i] = F[t][st + i] + ad;
                F[nt][st + len + i] = F[t][st + i] - ad;
            }
        swap(t, nt);
    }
    for (int i = 0; i < L; i++)
        A[i] = F[t][i];
    return;
}

cd A[N], B[N];
char s[N];
int a[N];
int ans[N];
int n;

void solve()
{
    scanf("%d %s", &n, s);
    int k = 0;
    while((1 << k) < (2 * n)) k++;
    int L = 1 << k;
    for (int i = 0; i < L; i++)
        A[i] = B[i] = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'V')
            A[i] = 1;
        else if (s[i] == 'K')
            B[n - i] = 1;
    }
    FFT(A, k);
    FFT(B, k);
    for (int i = 0; i < L; i++)
        A[i] *= B[i];
    FFT(A, k);
    for (int i = 0; i < L; i++)
        a[i] = (int)(A[i].real() + 0.5);
    reverse(a + 1, a + L);
    for (int d = 1; d <= n; d++)
        ans[d] = 1;
    for (int d = 1; d <= n; d++)
        if (a[n - d] + a[n + d])
            ans[d] = 0;
    int cnt = 0;
    for (int x = 1; x <= n; x++) {
        for (int y = x; y <= n; y += x)
            ans[x] &= ans[y];
        cnt += ans[x];
    }
    printf("%d\n", cnt);
    for (int i = 1; i <= n; i++)
        if (ans[i])
            printf("%d ", i);
    printf("\n");
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    initFFT();

    int t;
    scanf("%d", &t);
    while(t--) solve();

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef complex<float> cd;
double PI = 4 * atan(1);

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int LOG = 20;
const int N = 1 << LOG;
const int NN = N + 5;
cd w[NN];
int rev[NN];

void initFFT()
{
    for (int i = 0; i < N; i++)
        w[i] = cd(cos(2 * PI * i / N), sin(2 * PI * i / N));
    rev[0] = 0;
    for (int mask = 1; mask < N; mask++) {
        int k = 0;
        while(((mask >> k) & 1) == 0) k++;
        rev[mask] = rev[mask ^ (1 << k)] ^ (1 << (LOG - 1 - k));
    }
}

cd F[2][NN];
void FFT(cd* A, int k)
{
    int L = 1 << k;
    for (int mask = 0; mask < L; mask++)
        F[0][rev[mask] >> (LOG - k)] = A[mask];
    int t = 0, nt = 1;
    for (int lvl = 0; lvl < k; lvl++) {
        int len = 1 << lvl;
        for (int st = 0; st < L; st += (len << 1))
            for (int i = 0; i < len; i++) {
                cd ad = F[t][st + len + i] * w[i << (LOG - 1 - lvl)];
                F[nt][st + i] = F[t][st + i] + ad;
                F[nt][st + len + i] = F[t][st + i] - ad;
            }
        swap(t, nt);
    }
    for (int i = 0; i < L; i++)
        A[i] = F[t][i];
    return;
}

cd A[NN], B[NN];
char s[NN];
int a[NN];
int ans[NN];
int n;

void solve()
{
    scanf("%d %s", &n, s);
    int k = 0;
    while((1 << k) < (2 * n)) k++;
    if (k > 5) {
        int L = 1 << k;
        for (int i = 0; i < L; i++)
            A[i] = B[i] = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'V')
                A[i] = 1;
            else if (s[i] == 'K')
                B[n - i] = 1;
        }
        FFT(A, k);
        FFT(B, k);
        for (int i = 0; i < L; i++)
            A[i] *= B[i];
        FFT(A, k);
        for (int i = 0; i < L; i++)
            a[i] = (int)(A[i].real() + 0.5);
        reverse(a + 1, a + L);
        for (int d = 1; d <= n; d++)
            ans[d] = 1;
        for (int d = 1; d <= n; d++)
            if (a[n - d] + a[n + d] > 0)
                ans[d] = 0;
    } else {
        for (int d = 1; d <= n; d++) {
            ans[d] = 1;
            for (int i = 0; i + d < n; i++) {
                if (s[i] != s[i + d] && s[i] != '?' && s[i + d] != '?')
                    ans[d] = 0;
            }
        }
    }
    int cnt = 0;
    for (int x = 1; x <= n; x++) {
        for (int y = x + x; y <= n; y += x)
            ans[x] &= ans[y];
        cnt += ans[x];
    }
    printf("%d\n", cnt);
    for (int i = 1; i <= n; i++)
        if (ans[i])
            printf("%d ", i);
    printf("\n");
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    initFFT();

    int t;
    scanf("%d", &t);
    while(t--) solve();

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef complex<double> cd;
double PI = 4 * atan(1.);

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int LOG = 20;
const int N = 1 << LOG;
const int NN = N + 5;
cd w[NN];
int rev[NN];

void initFFT()
{
    for (int i = 0; i < N; i++)
        w[i] = cd(cos(2 * PI * i / N), sin(2 * PI * i / N));
    rev[0] = 0;
    for (int mask = 1; mask < N; mask++) {
        int k = 0;
        while(((mask >> k) & 1) == 0) k++;
        rev[mask] = rev[mask ^ (1 << k)] ^ (1 << (LOG - 1 - k));
    }
}

cd F[2][NN];
void FFT(cd* A, int k)
{
    int L = 1 << k;
    for (int mask = 0; mask < L; mask++)
        F[0][rev[mask] >> (LOG - k)] = A[mask];
    int t = 0, nt = 1;
    for (int lvl = 0; lvl < k; lvl++) {
        int len = 1 << lvl;
        for (int st = 0; st < L; st += (len << 1))
            for (int i = 0; i < len; i++) {
                cd ad = F[t][st + len + i] * w[i << (LOG - 1 - lvl)];
                F[nt][st + i] = F[t][st + i] + ad;
                F[nt][st + len + i] = F[t][st + i] - ad;
            }
        swap(t, nt);
    }
    for (int i = 0; i < L; i++)
        A[i] = F[t][i];
    return;
}

cd A[NN], B[NN];
char s[NN];
int a[NN];
int ans[NN];
int n;

void solve()
{
    scanf("%d %s", &n, s);
    int k = 0;
    while((1 << k) < (2 * n + 3)) k++;
    if (k > 5) {
        int L = 1 << k;
        for (int i = 0; i < L; i++)
            A[i] = B[i] = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'V')
                A[i] = 1;
            else if (s[i] == 'K')
                B[n - i] = 1;
        }
        FFT(A, k);
        FFT(B, k);
        for (int i = 0; i < L; i++)
            A[i] *= B[i];
        FFT(A, k);
        for (int i = 0; i < L; i++)
            a[i] = (int)(A[i].real() / L + 0.5);
        reverse(a + 1, a + L);
        for (int d = 1; d <= n; d++)
            ans[d] = 1;
        for (int d = 1; d < n; d++)
            if (a[n - d] + a[n + d] > 0)
                ans[d] = 0;
    } else {
        for (int d = 1; d <= n; d++) {
            ans[d] = 1;
            for (int i = 0; i + d < n; i++) {
                if (s[i] != s[i + d] && s[i] != '?' && s[i + d] != '?')
                    ans[d] = 0;
            }
        }
    }
    int cnt = 0;
    for (int x = 1; x <= n; x++) {
        for (int y = x + x; y <= n; y += x)
            ans[x] &= ans[y];
        cnt += ans[x];
    }
    printf("%d\n", cnt);
    for (int i = 1; i <= n; i++)
        if (ans[i])
            printf("%d ", i);
    printf("\n");
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    initFFT();

    int t;
    scanf("%d", &t);
    while(t--) solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const double PI = acos(-1.0);

struct Complex{
    double x, y;
    Complex(double _x = 0.0, double _y = 0.0){
        x = _x, y = _y;
    }
    Complex operator - (const Complex &b) const{
        return Complex(x - b.x, y - b.y);
    }
    Complex operator + (const Complex &b) const{
        return Complex(x + b.x, y + b.y);
    }
    Complex operator * (const Complex &b) const{
        return Complex(x * b.x - y * b.y, x * b.y + y * b.x);
    }
};

void change(Complex y[], int len){
    int i, j, k;
    for(i = 1, j = len/2; i < len - 1; i++){
        if(i < j){Complex tmp = y[i]; y[i] = y[j], y[j] = tmp;}
        k = len / 2;
        while(j >= k){
            j = j - k;
            k = k / 2;
        }
        if(j < k) j += k;
    }
}

void fft(Complex y[], int len, int on){
    change(y, len);
    for(int h = 2; h <= len; h <<= 1){
        Complex wn(cos(-on*2*PI/h), sin(-on*2*PI/h));
        for(int j = 0; j < len; j += h){
            Complex w(1,0);
            for(int k = j; k < j + h/2; k++){
                Complex u = y[k];
                Complex t = w * y[k + h/2];
                y[k] = u + t;
                y[k + h/2] = u - t;
                w = w * wn;
            }
        }
    }
    if(on == -1){
        for(int i = 0; i < len; i++){
            y[i].x /= len;
        }
    }
}

const int N = 110000;

int n, len;
string str;
vector<int> a;
Complex x1[N], x2[N];
int ans[N];
vector<int> res;

vector<int> get(int type) {
    for(int i = 0; i < len; i++) x1[i] = x2[i] = Complex(0, 0);
    a = vector<int>(n, 0);
    for(int i = 0; i < n; i++) {
        if(type == 1) a[i] = (str[i] != '?');
        else if(type == 2) a[i] = (str[i] == 'V');
        else a[i] = (str[i] == 'K');
    }
    for(int i = 0; i < n; i++) {
        x1[i] = Complex(a[i], 0);
        x2[n - 1 - i] = Complex(a[i], 0);
    }
    fft(x1, len, 1);
    fft(x2, len, 1);
    for(int i = 0; i < len; i++) x1[i] = x1[i] * x2[i];
    fft(x1, len, -1);
    vector<int> res(n, 0);
    for(int i = 0; i < n; i++) res[i] = (int)(x1[i].x + 0.5);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;
    while(T--) {
        cin >> n >> str;
        res.clear();
        len = 1;
        while(len < 2 * n) len *= 2;
        auto s = get(1);

        auto a = get(2);
        auto b = get(3);
        fill(ans, ans + n + 1, 0);
        for(int j = n - 2; j >= 0; j--) {
            if(a[j] + b[j] == s[j]) ans[n - 1 - j] = 1;
        }
        ans[n] = 1;
        for(int i = 1; i <= n; i++) {
            for(int j = i * 2; j <= n; j++) if(!ans[j]) ans[i] = 0;
        }
        int cnt = 0;
        for(int j = 1; j <= n; j++) cnt += (ans[j] == 1);
        cout << cnt << '\n';
        for(int j = 1; j <= n; j++) if(ans[j]) cout << j << " ";
        cout << '\n';

    }

}


#include <bits/stdc++.h>
using namespace std;

const double PI = acos(-1.0);

struct Complex{
    double x, y;
    Complex(double _x = 0.0, double _y = 0.0){
        x = _x, y = _y;
    }
    Complex operator - (const Complex &b) const{
        return Complex(x - b.x, y - b.y);
    }
    Complex operator + (const Complex &b) const{
        return Complex(x + b.x, y + b.y);
    }
    Complex operator * (const Complex &b) const{
        return Complex(x * b.x - y * b.y, x * b.y + y * b.x);
    }
};

void change(Complex y[], int len){
    int i, j, k;
    for(i = 1, j = len/2; i < len - 1; i++){
        if(i < j){Complex tmp = y[i]; y[i] = y[j], y[j] = tmp;}
        k = len / 2;
        while(j >= k){
            j = j - k;
            k = k / 2;
        }
        if(j < k) j += k;
    }
}

void fft(Complex y[], int len, int on){
    change(y, len);
    for(int h = 2; h <= len; h <<= 1){
        Complex wn(cos(-on*2*PI/h), sin(-on*2*PI/h));
        for(int j = 0; j < len; j += h){
            Complex w(1,0);
            for(int k = j; k < j + h/2; k++){
                Complex u = y[k];
                Complex t = w * y[k + h/2];
                y[k] = u + t;
                y[k + h/2] = u - t;
                w = w * wn;
            }
        }
    }
    if(on == -1){
        for(int i = 0; i < len; i++){
            y[i].x /= len;
        }
    }
}

const int N = 1100000;

int n, len;
string str;
vector<int> a;
Complex x1[N], x2[N];
int ans[N];
vector<int> res;

vector<int> get(int type) {
    for(int i = 0; i < len; i++) x1[i] = x2[i] = Complex(0, 0);
    a = vector<int>(n, 0);
    for(int i = 0; i < n; i++) {
        if(type == 1) a[i] = (str[i] != '?');
        else if(type == 2) a[i] = (str[i] == 'V');
        else a[i] = (str[i] == 'K');
    }
    for(int i = 0; i < n; i++) {
        x1[i] = Complex(a[i], 0);
        x2[n - 1 - i] = Complex(a[i], 0);
    }
    fft(x1, len, 1);
    fft(x2, len, 1);
    for(int i = 0; i < len; i++) x1[i] = x1[i] * x2[i];
    fft(x1, len, -1);
    vector<int> res(n, 0);
    for(int i = 0; i < n; i++) res[i] = (int)(x1[i].x + 0.5);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;
    while(T--) {
        cin >> n >> str;
        res.clear();
        len = 1;
        while(len < 2 * n) len *= 2;
        auto s = get(1);

        auto a = get(2);
        auto b = get(3);
        fill(ans, ans + n + 1, 0);
        for(int j = n - 2; j >= 0; j--) {
            if(a[j] + b[j] == s[j]) ans[n - 1 - j] = 1;
        }
        ans[n] = 1;
        for(int i = 1; i <= n; i++) {
            for(int j = i * 2; j <= n; j += i) if(!ans[j]) ans[i] = 0;
        }
        int cnt = 0;
        for(int j = 1; j <= n; j++) cnt += (ans[j] == 1);
        cout << cnt << '\n';
        for(int j = 1; j <= n; j++) if(ans[j]) cout << j << " ";
        cout << '\n';

    }

}


#include <bits/stdc++.h>
using namespace std;

const double PI = acos(-1.0);

struct Complex{
    double x, y;
    Complex(double _x = 0.0, double _y = 0.0){
        x = _x, y = _y;
    }
    Complex operator - (const Complex &b) const{
        return Complex(x - b.x, y - b.y);
    }
    Complex operator + (const Complex &b) const{
        return Complex(x + b.x, y + b.y);
    }
    Complex operator * (const Complex &b) const{
        return Complex(x * b.x - y * b.y, x * b.y + y * b.x);
    }
};

void change(Complex y[], int len){
    int i, j, k;
    for(i = 1, j = len/2; i < len - 1; i++){
        if(i < j){Complex tmp = y[i]; y[i] = y[j], y[j] = tmp;}
        k = len / 2;
        while(j >= k){
            j = j - k;
            k = k / 2;
        }
        if(j < k) j += k;
    }
}

void fft(Complex y[], int len, int on){
    change(y, len);
    for(int h = 2; h <= len; h <<= 1){
        Complex wn(cos(-on*2*PI/h), sin(-on*2*PI/h));
        for(int j = 0; j < len; j += h){
            Complex w(1,0);
            for(int k = j; k < j + h/2; k++){
                Complex u = y[k];
                Complex t = w * y[k + h/2];
                y[k] = u + t;
                y[k + h/2] = u - t;
                w = w * wn;
            }
        }
    }
    if(on == -1){
        for(int i = 0; i < len; i++){
            y[i].x /= len;
        }
    }
}

const int N = 1100000;

int n, len;
string str;
vector<int> a;
Complex x1[N], x2[N];
int ans[N];
vector<int> res;

vector<int> get(int type) {
    for(int i = 0; i < len; i++) x1[i] = x2[i] = Complex(0, 0);
    a = vector<int>(n, 0);
    for(int i = 0; i < n; i++) {
        if(type == 1) a[i] = (str[i] != '?');
        else if(type == 2) a[i] = (str[i] == 'V');
        else a[i] = (str[i] == 'K');
    }
    for(int i = 0; i < n; i++) {
        x1[i] = Complex(a[i], 0);
        x2[n - 1 - i] = Complex(a[i], 0);
    }
    fft(x1, len, 1);
    fft(x2, len, 1);
    for(int i = 0; i < len; i++) x1[i] = x1[i] * x2[i];
    fft(x1, len, -1);
    vector<int> res(n, 0);
    for(int i = 0; i < n; i++) res[i] = (int)(x1[i].x + 0.5);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;
    while(T--) {
        cin >> n >> str;
        res.clear();
        len = 1;
        while(len < 2 * n) len *= 2;
        auto s = get(1);

        auto a = get(2);
        auto b = get(3);
        fill(ans, ans + n + 1, 0);
        for(int j = n - 2; j >= 0; j--) {
            if(a[j] + b[j] == s[j]) ans[n - 1 - j] = 1;
        }
        ans[n] = 1;
        for(int i = 1; i <= n; i++) {
            for(int j = i * 2; j <= n; j++) if(!ans[j]) ans[i] = 0;
        }
        int cnt = 0;
        for(int j = 1; j <= n; j++) cnt += (ans[j] == 1);
        cout << cnt << '\n';
        for(int j = 1; j <= n; j++) if(ans[j]) cout << j << " ";
        cout << '\n';

    }

}


#include <bits/stdc++.h>
using namespace std;

const double PI = acos(-1.0);

struct Complex{
    double x, y;
    Complex(double _x = 0.0, double _y = 0.0){
        x = _x, y = _y;
    }
    Complex operator - (const Complex &b) const{
        return Complex(x - b.x, y - b.y);
    }
    Complex operator + (const Complex &b) const{
        return Complex(x + b.x, y + b.y);
    }
    Complex operator * (const Complex &b) const{
        return Complex(x * b.x - y * b.y, x * b.y + y * b.x);
    }
};

void change(Complex y[], int len){
    int i, j, k;
    for(i = 1, j = len/2; i < len - 1; i++){
        if(i < j){Complex tmp = y[i]; y[i] = y[j], y[j] = tmp;}
        k = len / 2;
        while(j >= k){
            j = j - k;
            k = k / 2;
        }
        if(j < k) j += k;
    }
}

void fft(Complex y[], int len, int on){
    change(y, len);
    for(int h = 2; h <= len; h <<= 1){
        Complex wn(cos(-on*2*PI/h), sin(-on*2*PI/h));
        for(int j = 0; j < len; j += h){
            Complex w(1,0);
            for(int k = j; k < j + h/2; k++){
                Complex u = y[k];
                Complex t = w * y[k + h/2];
                y[k] = u + t;
                y[k + h/2] = u - t;
                w = w * wn;
            }
        }
    }
    if(on == -1){
        for(int i = 0; i < len; i++){
            y[i].x /= len;
        }
    }
}

const int N = 1e6;

int n, len;
string str;
vector<int> a;
Complex x1[N], x2[N];
int ans[N];
vector<int> res;

vector<int> get(int type) {
    for(int i = 0; i < len; i++) x1[i] = x2[i] = Complex(0, 0);
    a = vector<int>(n, 0);
    for(int i = 0; i < n; i++) {
        if(type == 1) a[i] = (str[i] != '?');
        else if(type == 2) a[i] = (str[i] == 'V');
        else a[i] = (str[i] == 'K');
    }
    for(int i = 0; i < n; i++) {
        x1[i] = Complex(a[i], 0);
        x2[n - 1 - i] = Complex(a[i], 0);
    }
    fft(x1, len, 1);
    fft(x2, len, 1);
    for(int i = 0; i < len; i++) x1[i] = x1[i] * x2[i];
    fft(x1, len, -1);
    vector<int> res(n, 0);
    for(int i = 0; i < n; i++) res[i] = (int)(x1[i].x + 0.5);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;
    while(T--) {
        cin >> n >> str;
        res.clear();
        len = 1;
        while(len < 2 * n) len *= 2;
        auto s = get(1);

        auto a = get(2);
        auto b = get(3);
        fill(ans, ans + n + 1, 0);
        for(int j = n - 2; j >= 0; j--) {
            if(a[j] + b[j] == s[j]) ans[n - 1 - j] = 1;
        }
        ans[n] = 1;
        for(int i = 1; i <= n; i++) {
            for(int j = i * 2; j <= n; j++) if(!ans[j]) ans[i] = 0;
        }
        int cnt = 0;
        for(int j = 1; j <= n; j++) cnt += (ans[j] == 1);
        cout << cnt << '\n';
        for(int j = 1; j <= n; j++) if(ans[j]) cout << j << " ";
        cout << '\n';

    }

}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define p 998244353
using namespace std;
namespace ywy{
	char str[555555];
	inline ll mi(int a,int b){
		ll ans=1,tmp=a;while(b){
			if(b&1)ans=(ans*tmp)%p;tmp=(tmp*tmp)%p;b>>=1;
		}return(ans);
	}int hudie[1048577];unsigned char can[300];
	inline int get(){
		char c;int ptr=1;while((c=getchar())||23333)if(can[c])break;
		str[ptr]=c;ptr++;while((c=getchar())||23333){
			if(can[c])str[ptr]=c,ptr++;else return(ptr-1);
		}
	}
	void print(int num){
		if(num>=10)print(num/10);putchar(num%10+'0');
	}ll a[1048577],b[1048577],f[1048577];
	inline void ntt(int n,ll *f,ll g){
		for(register int i=0;i<n;i++)if(i<hudie[i])swap(f[i],f[hudie[i]]);
		for(register int bit=2;bit<=n;bit<<=1){
			ll dk=mi(g,(p-1)/bit);for(register int i=0;i<n;i+=bit){
				ll dwg=1;for(register int j=i;j<i+(bit>>1);j++){
					ll cjr=(f[j+(bit>>1)]*dwg)%p;f[j+(bit>>1)]=(f[j]+p-cjr)%p;f[j]=(f[j]+cjr)%p;dwg=(dwg*dk)%p;
				}
			}
		}
	}unsigned char res[555555];
	void ywymain(){
		can['V']=can['?']=can['K']=1;int t;cin>>t;while(t){
			t--;int n;cin>>n;scanf("%s",str+1);
			int k=1;while(k<=n+n)k<<=1;
			for(register int i=0;i<k;i++)hudie[i]=(hudie[i>>1]>>1)|((i&1)?(k>>1):0);
			for(register int i=1;i<=n;i++){
				if(str[i]=='K')a[i]=1;if(str[n-i+1]=='V')b[i]=1;
			}ntt(k,a,3);ntt(k,b,3);for(register int i=0;i<k;i++)a[i]=(a[i]*b[i])%p;ntt(k,a,mi(3,p-2));
			ll inv=mi(k,p-2);for(register int i=1;i<=n+1;i++)f[i]=(a[i]*inv)%p;
			for(register int i=0;i<k;i++)a[i]=b[i]=0;
			for(register int i=1;i<=n;i++){
				if(str[i]=='V')a[i]=1;if(str[n-i+1]=='K')b[i]=1;res[i]=0;
			}ntt(k,a,3);ntt(k,b,3);for(register int i=0;i<k;i++)a[i]=(a[i]*b[i])%p;ntt(k,a,mi(3,p-2));
			for(register int i=1;i<=n+1;i++)f[i]=(f[i]+a[i]*inv)%p;int ans=0;
			for(register int i=n;i>=1;i--){
				if(f[n-i+1])continue;for(register int j=i;j<=n;j+=i)if(f[n-j+1])goto s;ans++;res[i]=1;s:;
			}print(ans);putchar('\n');for(register int i=1;i<=n;i++){
				if(res[i])print(i),putchar(' ');
			}putchar('\n');for(register int i=0;i<k;i++)a[i]=b[i]=0;
		}
	}
}
int main(){
	ywy::ywymain();return(0);
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define p 998244353
using namespace std;
namespace ywy{
	char str[555555];
	inline ll mi(int a,int b){
		ll ans=1,tmp=a;while(b){
			if(b&1)ans=(ans*tmp)%p;tmp=(tmp*tmp)%p;b>>=1;
		}return(ans);
	}int hudie[1048577];unsigned char can[300];
	inline int get(){
		char c;int ptr=1;while((c=getchar())||23333)if(can[c])break;
		str[ptr]=c;ptr++;while((c=getchar())||23333){
			if(can[c])str[ptr]=c,ptr++;else return(ptr-1);
		}
	}
	void print(int num){
		if(num>=10)print(num/10);putchar(num%10+'0');
	}ll a[1048577],b[1048577],f[1048577];
	inline void ntt(int n,ll *f,ll g){
		for(register int i=0;i<n;i++)if(i<hudie[i])swap(f[i],f[hudie[i]]);
		for(register int bit=2;bit<=n;bit<<=1){
			ll dk=mi(g,(p-1)/bit);for(register int i=0;i<n;i+=bit){
				ll dwg=1;for(register int j=i;j<i+(bit>>1);j++){
					ll cjr=(f[j+(bit>>1)]*dwg)%p;f[j+(bit>>1)]=(f[j]+p-cjr)%p;f[j]=(f[j]+cjr)%p;dwg=(dwg*dk)%p;
				}
			}
		}
	}unsigned char res[555555];ll c[1048577],d[1048577],vim[1048577];
	void ywymain(){
		can['V']=can['?']=can['K']=1;int t;cin>>t;ll dg=mi(3,p-2);
		int dk=1;while(dk<=1048576)vim[dk]=mi(dk,p-2),dk<<=1;while(t){
			t--;int n;scanf("%d",&n);get();
			int k=1;while(k<=n+n)k<<=1;
			for(register int i=0;i<k;i++)hudie[i]=(hudie[i>>1]>>1)|((i&1)?(k>>1):0);
			for(register int i=1;i<=n;i++){
				if(str[i]=='V')c[i]=1;if(str[n-i+1]=='K')d[i]=1;res[i]=0;
				if(str[i]=='K')a[i]=1;if(str[n-i+1]=='V')b[i]=1;
			}ntt(k,a,3);ntt(k,b,3);ntt(k,c,3);ntt(k,d,3);
			for(register int i=0;i<k;i++)a[i]=(a[i]*b[i])%p,c[i]=(c[i]*d[i])%p;ntt(k,a,dg);ntt(k,c,dg);
			int ans=0;for(register int i=n;i>=1;i--){
				if(a[n-i+1]||c[n-i+1])continue;for(register int j=i;j<=n;j+=i)if(a[n-j+1]||c[n-j+1])goto s;
				ans++;res[i]=1;s:;
			}print(ans);putchar('\n');for(register int i=1;i<=n;i++){
				if(res[i])print(i),putchar(' ');
			}putchar('\n');for(register int i=0;i<k;i++)a[i]=b[i]=c[i]=d[i]=0;
		}
	}
}
int main(){
	ywy::ywymain();return(0);
}


#include <iostream>
#include <complex>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
const int nmax=(1<<20)+5;
const double pi=acos(-1.0);
struct cpx
{
    double re,im;
};//modifica long double daca e necesar
cpx operator +  (cpx unu,cpx doi) {return {unu.re+doi.re,unu.im+doi.im};}
cpx operator - (cpx unu,cpx doi)  {return {unu.re-doi.re,unu.im-doi.im};}
cpx operator * (cpx unu,cpx doi) {return {unu.re*doi.re-unu.im*doi.im,unu.re*doi.im+unu.im*doi.re};}
cpx p1[nmax],p2[nmax],p3[nmax];
string s;
int a[nmax],b[nmax],ok[nmax],c[nmax];
int o[nmax];
int i,lim,lg,j,t,n;
void fft(cpx v[],double rev)
{
    double L;
    cpx U,V,root,put;
    for(i=0;i<lim;i++)
      if(i<o[i])
          swap(v[i],v[o[i]]);
    for(int l=1;l<lim;l*=2)
    {
        L=2*l;
        root={cos(2*pi/L),sin(2*pi/L)*rev};
        for(i=0;i<lim;i+=2*l)
        {
            put={1,0};
            for(j=0;j<l;j++)
            {
                U=v[i+j];V=v[i+j+l];
                v[i+j]=U+V*put;
                v[i+j+l]=U-V*put;
                put=put*root;
            }
        }
    }
    if(rev==-1)
    {
        L=lim;
        for(i=0;i<lim;i++)
            v[i].re/=L,v[i].im/=L;
    }
}
void mult(int A[],int B[],int C[])
{
    for(i=0;i<lim;i++)
    {
        o[i]=0;
        for(j=0;j<lg;j++)
            if(((1<<j)&i))
               o[i]|=(1<<(lg-j-1));
    }
    for(i=0;i<lim;i++)
       p1[i]={(double)A[i],0},p2[i]={(double)B[i],0};
     fft(p1,1);
     fft(p2,1);
     for(i=0;i<lim;i++)
         p3[i]=p1[i]*p2[i];
     fft(p3,-1);
     for(i=0;i<lim;i++)
     {
         C[i]=(int)round(p3[i].re);
         p1[i]=p2[i]=p3[i]={0,0};
     }
}
int main()
{
   // freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>t;
    for(int cnt=1;cnt<=t;cnt++)
    {
        cin>>n;
        cin>>s;
        s=" "+s;
        for(i=1;i<=n;i++)
        {
            if(s[i]=='V') a[i]=1;
            if(s[i]=='K') b[n-i]=1;
        }
        lg=0;lim=1;
        while(lim<=2*n)
            lim*=2,lg++;
        mult(a,b,c);
        for(i=1;i<=n;i++)
            ok[i]=1;
        for(i=0;i<lim;i++)
        {
            if(c[i])
                ok[max(i-n,n-i)]=0;
            a[i]=b[i]=c[i]=0;
        }
        for(i=1;i<=n;i++)
            for(j=2*i;j<=n;j+=i)
              ok[i]&=ok[j];
        int bune=0;
        for(i=1;i<=n;i++)
            if(ok[i])
              bune++;
        cout<<bune<<'\n';
        for(i=1;i<=n;i++)
            if(ok[i])
               cout<<i<<' ';
        cout<<'\n';
    }
    return 0;
}


#include <iostream>
#include <complex>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
const int nmax=(1<<20)+5;
const int pi=acos(-1.0);
complex<double> p1[nmax],p2[nmax],p3[nmax];
string s;
int a[nmax],b[nmax],ok[nmax],c[nmax];
int o[nmax];
int i,lim,lg,j,t,n;
void fft(complex<double> v[],double rev)
{
    double L;
    complex<double> U,V,root,put;
    for(i=0;i<lim;i++)
      if(i<o[i])
          swap(v[i],v[o[i]]);
    for(int l=1;l<lim;l*=2)
    {
        L=2*l;
        root={cos(2*pi/L),sin(2*pi/L)*rev};
        for(i=0;i<lim;i+=2*l)
        {
            put={1,0};
            for(j=0;j<l;j++)
            {
                U=v[i+j];V=v[i+j+l];
                v[i+j]=U+V*put;
                v[i+j+l]=U-V*put;
                put*=root;
            }
        }
    }
    if(rev==-1)
    {
        L=lim;
        for(i=0;i<lim;i++)
            v[i]/=L;
    }
}
void mult(int A[],int B[],int C[])
{
    for(i=0;i<lim;i++)
    {
        o[i]=0;
        for(j=0;j<lg;j++)
            if(((1<<j)&i))
               o[i]|=(1<<(lg-j-1));
    }
    for(i=0;i<lim;i++)
       p1[i]={(double)A[i],0},p2[i]={(double)B[i],0};
     fft(p1,1);
     fft(p2,1);
     for(i=0;i<lim;i++)
         p3[i]=p1[i]*p2[i];
     fft(p3,-1);
     for(i=0;i<lim;i++)
     {
         C[i]=(int)floor(p3[i].real()+0.5);
         p1[i]=p2[i]=p3[i]={0,0};
     }
}
int main()
{
   // freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>t;
    for(int cnt=1;cnt<=t;cnt++)
    {
        cin>>n;
        cin>>s;
        s=" "+s;
        for(i=1;i<=n;i++)
        {
            if(s[i]=='V') a[i]=1;
            if(s[i]=='K') b[n-i]=1;
        }
        lg=0;lim=1;
        while(lim<=2*n)
            lim*=2,lg++;
        mult(a,b,c);
        for(i=1;i<=n;i++)
            ok[i]=1;
        for(i=0;i<lim;i++)
        {
            if(c[i])
                ok[max(i-n,n-i)]=0;
            a[i]=b[i]=c[i]=0;
        }
        for(i=1;i<=n;i++)
            for(j=2*i;j<=n;j+=i)
              ok[i]&=ok[j];
        int bune=0;
        for(i=1;i<=n;i++)
            if(ok[i])
              bune++;
        cout<<bune<<'\n';
        for(i=1;i<=n;i++)
            if(ok[i])
               cout<<i<<' ';
        cout<<'\n';
    }
    return 0;
}


#include <iostream>
#include <complex>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
const int nmax=(1<<20)+5;
const double pi=acos(-1.0);//*facepalm*
complex<double> p1[nmax],p2[nmax],p3[nmax];
string s;
int a[nmax],b[nmax],ok[nmax],c[nmax];
int o[nmax];
int i,lim,lg,j,t,n;
void fft(complex<double> v[],double rev)
{
    double L;
    complex<double> U,V,root,put;
    for(i=0;i<lim;i++)
      if(i<o[i])
          swap(v[i],v[o[i]]);
    for(int l=1;l<lim;l*=2)
    {
        L=2*l;
        root={cos(2*pi/L),sin(2*pi/L)*rev};
        for(i=0;i<lim;i+=2*l)
        {
            put={1,0};
            for(j=0;j<l;j++)
            {
                U=v[i+j];V=v[i+j+l];
                v[i+j]=U+V*put;
                v[i+j+l]=U-V*put;
                put*=root;
            }
        }
    }
    if(rev==-1)
    {
        L=lim;
        for(i=0;i<lim;i++)
            v[i]/=L;
    }
}
void mult(int A[],int B[],int C[])
{
    for(i=0;i<lim;i++)
    {
        o[i]=0;
        for(j=0;j<lg;j++)
            if(((1<<j)&i))
               o[i]|=(1<<(lg-j-1));
    }
    for(i=0;i<lim;i++)
       p1[i]={(double)A[i],0},p2[i]={(double)B[i],0};
     fft(p1,1);
     fft(p2,1);
     for(i=0;i<lim;i++)
         p3[i]=p1[i]*p2[i];
     fft(p3,-1);
     for(i=0;i<lim;i++)
     {
         C[i]=(int)round(p3[i].real());
         p1[i]=p2[i]=p3[i]={0,0};
     }
}
int main()
{
   // freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>t;
    for(int cnt=1;cnt<=t;cnt++)
    {
        cin>>n;
        cin>>s;
        s=" "+s;
        for(i=1;i<=n;i++)
        {
            if(s[i]=='V') a[i]=1;
            if(s[i]=='K') b[n-i]=1;
        }
        lg=0;lim=1;
        while(lim<=2*n)
            lim*=2,lg++;
        mult(a,b,c);
        for(i=1;i<=n;i++)
            ok[i]=1;
        for(i=0;i<lim;i++)
        {
            if(c[i])
                ok[max(i-n,n-i)]=0;
            a[i]=b[i]=c[i]=0;
        }
        for(i=1;i<=n;i++)
            for(j=2*i;j<=n;j+=i)
              ok[i]&=ok[j];
        int bune=0;
        for(i=1;i<=n;i++)
            if(ok[i])
              bune++;
        cout<<bune<<'\n';
        for(i=1;i<=n;i++)
            if(ok[i])
               cout<<i<<' ';
        cout<<'\n';
    }
    return 0;
}


#include <iostream>
#include <complex>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
const int nmax=(1<<20)+5;
const int pi=acos(-1.0);
complex<double> p1[nmax],p2[nmax],p3[nmax];
string s;
int a[nmax],b[nmax],ok[nmax],c[nmax];
int o[nmax];
int i,lim,lg,j,t,n;
void fft(complex<double> v[],double rev)
{
    double L;
    complex<double> U,V,root,put;
    for(i=0;i<lim;i++)
      if(i<o[i])
          swap(v[i],v[o[i]]);
    for(int l=1;l<lim;l*=2)
    {
        L=2*l;
        root={cos(2*pi/L),sin(2*pi/L)*rev};
        for(i=0;i<lim;i+=2*l)
        {
            put={1,0};
            for(j=0;j<l;j++)
            {
                U=v[i+j];V=v[i+j+l];
                v[i+j]=U+V*put;
                v[i+j+l]=U-V*put;
                put*=root;
            }
        }
    }
    if(rev==-1)
    {
        L=lim;
        for(i=0;i<lim;i++)
            v[i]/=L;
    }
}
void mult(int A[],int B[],int C[])
{
    for(i=0;i<lim;i++)
    {
        o[i]=0;
        for(j=0;j<lg;j++)
            if(((1<<j)&i))
               o[i]|=(1<<(lg-j-1));
    }
    for(i=0;i<lim;i++)
       p1[i]={(double)A[i],0},p2[i]={(double)B[i],0};
     fft(p1,1);
     fft(p2,1);
     for(i=0;i<lim;i++)
         p3[i]=p1[i]*p2[i];
     fft(p3,-1);
     for(i=0;i<lim;i++)
     {
         C[i]=(int)round(p3[i].real());
         p1[i]=p2[i]=p3[i]={0,0};
     }
}
int main()
{
   // freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>t;
    for(int cnt=1;cnt<=t;cnt++)
    {
        cin>>n;
        cin>>s;
        s=" "+s;
        for(i=1;i<=n;i++)
            a[i]=b[i]=0;
        for(i=1;i<=n;i++)
        {
            if(s[i]=='V') a[i]=1;
            if(s[i]=='K') b[n-i]=1;
        }
        lg=0;lim=1;
        while(lim<=2*n)
            lim*=2,lg++;
        mult(a,b,c);
        for(i=1;i<=n;i++)
            ok[i]=1;
        for(i=0;i<lim;i++)
        {
            if(c[i])
                ok[max(i-n,n-i)]=0;
            a[i]=b[i]=c[i]=0;
        }
        for(i=1;i<=n;i++)
            for(j=2*i;j<=n;j+=i)
              ok[i]&=ok[j];
        int bune=0;
        for(i=1;i<=n;i++)
            if(ok[i])
              bune++;
        cout<<bune<<'\n';
        for(i=1;i<=n;i++)
            if(ok[i])
               cout<<i<<' ';
        cout<<'\n';
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<stack>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<sstream>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, int> pli;
inline void fre1()
{
    freopen("C:\\Users\\Administrator\\Desktop\\in.txt", "r", stdin);/*freopen("output.txt","w",stdout);*/
    freopen("C:\\Users\\Administrator\\Desktop\\out.txt", "w", stdout);
}
inline void fre2()
{
    fclose(stdin);/*fclose(stdout);*/
}
inline LL read()
{
    LL a = 0, f = 1; char c = getchar();
    while(!isdigit(c)){ if(c == '-') f = -1; c = getchar(); }
    while(isdigit(c)) (a *= 10) += c - '0', c = getchar() ;
    return a * f;
}
#define lowbit(x) (x&-x)//取x二进制数最小的1
#define MS(x, y) memset(x, y, sizeof(x))
#define MC(x, y) memcpy(x, y, sizeof(x))
#define lrt rt<<1
#define rrt rt<<1|1
#define lson l, mid, lrt
#define rson mid+1, r, rrt
#define rep(i, a, b) for(LL i = (a); i <= (b); ++i)
#define dwn(i, b, a) for(LL i = (b); i >= (a); --i)
const LL mod = 1e9 + 7;
const int maxn = 5e5 + 10;
const double PI = acos(-1), eps = 1e-10;
const int FFT_MAXN = 1 << 20;//FFT_MAXN就是大于(n + m)的最小的2^k(做fft长度必须为2^k)
struct cp
{
    double r, i;     //如果最后结果多项式数值达到了1e15以上，这里改换成long double
    cp(double _r = 0,double _i = 0) {r = _r; i = _i;}
    cp operator +(const cp &b) {return cp(r + b.r, i + b.i);}
    cp operator -(const cp &b) {return cp(r - b.r, i - b.i);}
    cp operator *(const cp &b) {return cp(r * b.r - i * b.i, r * b.i + i * b.r);}
};
void change(cp *y, int len)
{
    for(int i = 1, j = len / 2, k; i < len - 1; ++i)
    {
        if(i < j) swap(y[i], y[j]);
        k = len / 2;
        while(j >= k)
        {
            j -= k;
            k /= 2;
        }
        if(j < k) j += k;
    }
}
void dft(cp *y, int len, int on)
{
    change(y, len);
    for(int h = 2; h <= len; h <<= 1)
    {
        cp wn(cos(-on * 2 * PI / h), sin(-on * 2 * PI / h));
        for(int j = 0; j < len; j += h)
        {
            cp w(1, 0);
            for(int k = j; k < j + h / 2; ++k)
            {
                cp u = y[k];
                cp t = w * y[k + h / 2];
                y[k] = u + t;
                y[k + h / 2] = u - t;
                w = w * wn;
            }
        }
    }
    if(on == -1)
        for(int i = 0; i < len; ++i)
            y[i].r /= len;
}
void fft(int *a, int n, int *b, int m, LL *c)//注意n、m代表a数组下标从0到n，b数组下标从0到m（即a、b数组最后一位的下标n、m），所以下面对a数组b数组操作是，下标可以达到n和m
{
    static cp f[FFT_MAXN], g[FFT_MAXN];
    int len = 1;
    while(len <= (n + m))len <<= 1;
    for(int i = 0; i < len; ++i)    //这里其实可以<=，因为下面都是 i < len作为结束标识，所以这里len要大于n + m才可以
    {
        int aa = i <= n ? a[i] : 0;
        int bb = i <= m ? b[i] : 0;
        f[i] = cp(aa, 0);
        g[i] = cp(bb, 0);
    }
    dft(f, len, 1);
    dft(g, len, 1);
    for(int i = 0; i < len; ++i) f[i] = f[i] * g[i];
    dft(f, len, -1);
    for(int i = 0; i < len; ++i) c[i] = f[i].r + 0.5;
}
int t, n;
char s[maxn];
int a[maxn], b[maxn], ans[maxn];
LL c[FFT_MAXN];
vector<int> g[maxn];
bool vis[maxn];
int main()
{
    for(int i = 1; i <= 500000; ++i)for(int j = i; j <= 500000; j += i)g[j].push_back(i);
    scanf("%d", &t);
    while(t--)
    {
        scanf("%d%s", &n, s);
        for(int i = 0; i < n; ++i)a[i] = (s[i] == 'V' ? 1 : 0);
        for(int i = 0; i < n; ++i)b[i] = (s[n - 1 - i] == 'K' ? 1 : 0);
        fft(a, n - 1, b, n - 1, c);
        for(int i = n - 1; i >= 1; --i)if((c[n - 1 - i] || c[n - 1 + i]) && !vis[i])
        {
            for(int v: g[i])vis[v] = true;
        }
        int cnt = 0;
        for(int i = 1; i <= n; ++i)if(!vis[i])ans[cnt++] = i;
        printf("%d\n", cnt);
        for(int i = 0; i < cnt; ++i)printf("%d%c", ans[i], i == cnt - 1 ? '\n' : ' ');
        for(int i = 1; i <= n; ++i)vis[i] = 0;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<stack>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<sstream>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, int> pli;
inline void fre1()
{
    freopen("C:\\Users\\Administrator\\Desktop\\in.txt", "r", stdin);/*freopen("output.txt","w",stdout);*/
    freopen("C:\\Users\\Administrator\\Desktop\\out.txt", "w", stdout);
}
inline void fre2()
{
    fclose(stdin);/*fclose(stdout);*/
}
inline LL read()
{
    LL a = 0, f = 1; char c = getchar();
    while(!isdigit(c)){ if(c == '-') f = -1; c = getchar(); }
    while(isdigit(c)) (a *= 10) += c - '0', c = getchar() ;
    return a * f;
}
#define lowbit(x) (x&-x)//取x二进制数最小的1
#define MS(x, y) memset(x, y, sizeof(x))
#define MC(x, y) memcpy(x, y, sizeof(x))
#define lrt rt<<1
#define rrt rt<<1|1
#define lson l, mid, lrt
#define rson mid+1, r, rrt
#define rep(i, a, b) for(LL i = (a); i <= (b); ++i)
#define dwn(i, b, a) for(LL i = (b); i >= (a); --i)
const LL mod = 1e9 + 7;
const int maxn = 5e5 + 10;
const double PI = acos(-1), eps = 1e-10;
const int FFT_MAXN = 1 << 20;//FFT_MAXN就是大于(n + m)的最小的2^k(做fft长度必须为2^k)
struct cp
{
    double r, i;     //如果最后结果多项式数值达到了1e15以上，这里改换成long double
    cp(double _r = 0,double _i = 0) {r = _r; i = _i;}
    cp operator +(const cp &b) {return cp(r + b.r, i + b.i);}
    cp operator -(const cp &b) {return cp(r - b.r, i - b.i);}
    cp operator *(const cp &b) {return cp(r * b.r - i * b.i, r * b.i + i * b.r);}
};
void change(cp *y, int len)
{
    for(int i = 1, j = len / 2, k; i < len - 1; ++i)
    {
        if(i < j) swap(y[i], y[j]);
        k = len / 2;
        while(j >= k)
        {
            j -= k;
            k /= 2;
        }
        if(j < k) j += k;
    }
}
void dft(cp *y, int len, int on)
{
    change(y, len);
    for(int h = 2; h <= len; h <<= 1)
    {
        cp wn(cos(-on * 2 * PI / h), sin(-on * 2 * PI / h));
        for(int j = 0; j < len; j += h)
        {
            cp w(1, 0);
            for(int k = j; k < j + h / 2; ++k)
            {
                cp u = y[k];
                cp t = w * y[k + h / 2];
                y[k] = u + t;
                y[k + h / 2] = u - t;
                w = w * wn;
            }
        }
    }
    if(on == -1)
        for(int i = 0; i < len; ++i)
            y[i].r /= len;
}
void fft(int *a, int n, int *b, int m, LL *c)//注意n、m代表a数组下标从0到n，b数组下标从0到m（即a、b数组最后一位的下标n、m），所以下面对a数组b数组操作是，下标可以达到n和m
{
    static cp f[FFT_MAXN], g[FFT_MAXN];
    int len = 1;
    while(len <= (n + m))len <<= 1;
    for(int i = 0; i < len; ++i)    //这里其实可以<=，因为下面都是 i < len作为结束标识，所以这里len要大于n + m才可以
    {
        int aa = i <= n ? a[i] : 0;
        int bb = i <= m ? b[i] : 0;
        f[i] = cp(aa, 0);
        g[i] = cp(bb, 0);
    }
    dft(f, len, 1);
    dft(g, len, 1);
    for(int i = 0; i < len; ++i) f[i] = f[i] * g[i];
    dft(f, len, -1);
    for(int i = 0; i < len; ++i) c[i] = f[i].r + 0.5;
}
int t, n;
char s[maxn];
int a[maxn], b[maxn], ans[maxn];
LL c[FFT_MAXN];
vector<int> g[maxn];
bool vis[maxn];
int main()
{
    for(int i = 1; i <= 500000; ++i)for(int j = i; j <= 500000; j += i)g[j].push_back(i);
    scanf("%d", &t);
    while(t--)
    {
        scanf("%d%s", &n, s);
        for(int i = 0; i < n; ++i)a[i] = (s[i] == 'V' ? 1 : 0);
        for(int i = 0; i < n; ++i)b[i] = (s[n - 1 - i] == 'K' ? 1 : 0);
        fft(a, n - 1, b, n - 1, c);
        for(int i = n - 1; i >= 1; --i)if(c[n - 1 - i] && !vis[i])
        {
            for(int v: g[i])vis[v] = true;
        }
        int cnt = 0;
        for(int i = 1; i <= n; ++i)if(!vis[i])ans[cnt++] = i;
        printf("%d\n", cnt);
        for(int i = 0; i < cnt; ++i)printf("%d%c", ans[i], i == cnt - 1 ? '\n' : ' ');
        for(int i = 1; i <= n; ++i)vis[i] = 0;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define pi acos(-1)
#define eps 1e-3
using namespace std;
typedef long long ll;
struct E
{
  double r,i;
  E(){}E(double _x,double _y){r=_x;i=_y;}
  E operator=(int x){return r=x,i=0,E(x,0);}
  E operator+(E x){return E(r+x.r,i+x.i);}
  E operator-(E x){return E(r-x.r,i-x.i);}
  E operator*(E x){return E(r*x.r-i*x.i,r*x.i+i*x.r);}
};
E A[1200010],B[1200010];
int n,m,N,M,L,r[1200010],T,flag[500010];
char a[1200010],b[1200010];
inline void clear(){for(int i=0;i<N;i++) a[i]=b[i]=0;}
inline void dft(E *a,int f)
{
  for(int i=0;i<N;i++) if(i>r[i]) swap(a[i],a[r[i]]);
  for(int i=1;i<N;i=i<<1)
  {
    E wn=E(cos(pi/i),f*sin(pi/i));
    for(int j=0;j<N;j+=i<<1)
    {
      E w=E(1,0);
      for(int k=0;k<i;k++,w=w*wn)
      {
      	E x=a[j+k],y=a[j+k+i]*w;
      	a[j+k]=x+y; a[j+k+i]=x-y;
	  }
	}
  }
  if(f==-1) for(int i=0;i<N;i++) a[i].r/=N;
}
inline void fft(E *a,E *b)
{
  dft(a,1); dft(b,1);
  for(int i=0;i<N;i++) a[i]=a[i]*b[i];
  dft(a,-1);
}
int main()
{
  cin>>T;
  while(T--)
  {
  	scanf("%d",&n);
	scanf("%s",&a);
	m=n*2; L=0;
	for(N=1;N<=m;N=N<<1) L++;
    for(int i=0;i<N;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(L-1));
	for(int i=0;i<N;i++) A[i]=0,B[i]=0;
	for(int i=0;i<n;i++)
	{
	  if(a[i]=='V') A[i]=1;
	  if(a[i]=='K') B[n-i-1]=1;
	}
    fft(A,B);

	for(int i=1;i<=n;i++) flag[i]=0;
	for(int i=1;i<=n;i++)
	  if(fabs(A[n-i-1].r)>eps || fabs(A[n+i-1].r)>eps) flag[i]=1;
	int ans=0;
	for(int i=1;i<=n;i++)
    {
      for(int j=i;j<=n;j+=i) flag[i]|=flag[j];
      ans+=(flag[i]==0);
	}
	printf("%d\n",ans);
	for(int i=1;i<=n;i++) if(flag[i]==0) printf("%d ",i); printf("\n");
  }
  return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define pi acos(-1)
#define eps 1e-3
using namespace std;
typedef long long ll;
struct E
{
  double r,i;
  E(){}E(double _x,double _y){r=_x;i=_y;}
  E operator=(int x){return r=x,i=0,E(x,0);}
  E operator+(E x){return E(r+x.r,i+x.i);}
  E operator-(E x){return E(r-x.r,i-x.i);}
  E operator*(E x){return E(r*x.r-i*x.i,r*x.i+i*x.r);}
};
E A[1200010],B[1200010];
int n,m,N,M,L,r[1200010],T,flag[500010];
char a[1200010],b[1200010];
inline void clear(){for(int i=0;i<N;i++) a[i]=b[i]=0;}
inline void dft(E *a,int f)
{
  for(int i=0;i<N;i++) if(i>r[i]) swap(a[i],a[r[i]]);
  for(int i=1;i<N;i=i<<1)
  {
    E wn=E(cos(pi/i),f*sin(pi/i));
    for(int j=0;j<N;j+=i<<1)
    {
      E w=E(1,0);
      for(int k=0;k<i;k++,w=w*wn)
      {
      	E x=a[j+k],y=a[j+k+i]*w;
      	a[j+k]=x+y; a[j+k+i]=x-y;
	  }
	}
  }
  if(f==-1) for(int i=0;i<N;i++) a[i].r/=N;
}
inline void fft(E *a,E *b)
{
  dft(a,1); dft(b,1);
  for(int i=0;i<N;i++) a[i]=a[i]*b[i];
  dft(a,-1);
}
int main()
{
  cin>>T;
  while(T--)
  {
  	scanf("%d",&n);
	scanf("%s",&a);
	m=n*2; L=0;
	for(N=1;N<=m;N=N<<1) L++;
    for(int i=0;i<N;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(L-1));
	for(int i=0;i<N;i++) A[i]=0,B[i]=0;
	for(int i=0;i<n;i++)
	{
	  if(a[i]=='V') A[i]=1;
	  if(a[i]=='K') B[n-i-1]=1;
	}
	fft(A,B);
    for(int i=1;i<=n;i++) flag[i]=0;
	for(int i=1;i<=n;i++)
	  if(fabs(A[n-i-1].r)>eps) flag[i]=1;
    int ans=0;
	for(int i=1;i<=n;i++)
    {
      for(int j=i;j<=n;j+=i) flag[i]|=flag[j];
      ans+=(flag[i]==0);
	}
	printf("%d\n",ans);
	for(int i=1;i<=n;i++) if(flag[i]==0) printf("%d ",i); printf("\n");
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MX = (1 << 20);
const double pi = acos(-1);

struct base {
	double x, y;

	base(double x = 0, double y = 0) : x(x), y(y) { }
	base operator + (const base& v) { return base(x + v.x, y + v.y); }
	base operator - (const base& v) { return base(x - v.x, y - v.y); }
	base operator * (const base& v) { return base(x * v.x - y * v.y, x * v.y + y * v.x); }
	void operator /= (int d) { x /= d; y /= d; }
	double real() { return x; }
	double imag() { return y; }
	void imag(double z) { y = z; }
};

int rev[MX];
base w[MX + 1];

void init(int n) {
	int log_n = 0;
	while ((n >> log_n) > 1) log_n++;

	for (int i = 0; i < n; i++) {
		rev[i] = 0;
		for (int j = 0; j < log_n; j++)
			rev[i] |= (i >> j & 1) << (log_n - 1 - j);

		if (rev[i] < i) rev[i] = i;
	}

	w[1] = base(1, 0);
	for (int p = 0; p < log_n - 1; p++) {
		double alpha = pi / (n >> (log_n - 1 - p));
		base cur(cos(alpha), sin(alpha));
		for (int j = (1 << p); j < (2 << p); j++) {
			w[2 * j] = w[j];
			w[2 * j + 1] = w[j] * cur;
		}
	}
}

void fft(base a[], int n, bool invert) {
	for (int i = 0; i < n; i++) {
		swap(a[i], a[rev[i]]);
		if (invert) a[i].imag(-1 * a[i].imag());
	}
	for (int len = 1; len < n; len *= 2)
		for (int i = 0; i < n; i += 2 * len)
			for (int j = i, k = i + len; j < i + len; j++, k++) {
				base t = a[k] * w[k - i];
				a[k] = a[j] - t;
				a[j] = a[j] + t;
			}
	if (invert) for (int i = 0; i < n; i++) a[i] /= n;
}

char s[MX];
base a[MX], b[MX];

int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		int n;
		scanf("%d %s", &n, s);

		int N = 1;
		while (N < 2 * n) N *= 2;

		for (int i = 0; i < N; i++) a[i] = b[i] = base();

		for (int i = 0; i < n; i++) {
			if (s[i] == 'V') a[i] = base(1, 0);
			if (s[i] == 'K') b[n - 1 - i] = base(1, 0);
		}

		init(N);

		fft(a, N, false);
		fft(b, N, false);

		for (int i = 0; i < N; i++) a[i] = a[i] * b[i];

		fft(a, N, true);

		vector<int> ans;
		for (int i = 1; i <= n; i++) {
			bool ok = true;
			for (int j = i; j < n; j += i)
				if (i<n && abs(a[n - 1 - j].real()) > 0.5)
					ok = false;
				if (i==n && abs(a[n - 1 + j].real()) > 0.5)
				    ok = false;

			if (ok) ans.push_back(i);
		}

		printf("%d\n", (int)ans.size());
		for (int x : ans) printf("%d ", x);
		printf("\n");
	}

	return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;

const double PI=acos(-1.0);
struct complex{
	double r,i;
	complex(){}
	complex(double r0,double i0){r=r0;i=i0;}
	complex operator + (const complex &B){return complex(r+B.r,i+B.i);}
	complex operator - (const complex &B){return complex(r-B.r,i-B.i);}
	complex operator * (const complex &B){return complex(r*B.r-i*B.i,i*B.r+r*B.i);}
};
void change(complex y[],int len){
	for (int i=1,j=len/2;i<len-1;i++){
		if (i<j) swap(y[i],y[j]);
		int k=len/2;
		while(j>=k){
			j-=k;
			k>>=1;
		}
		if(j<k) j+=k;
	}
}
void FFT(complex y[],int len,int on){
	change(y,len);
	for (int h=2;h<=len;h<<=1){
		complex wn=complex(cos((double)on*2*PI/h),sin((double)on*2*PI/h));
		for (int j=0;j<len;j+=h){
			complex w=complex(1,0);
			for (int k=j;k<j+h/2;k++){
				complex u=y[k],t=y[k+h/2]*w;
				y[k]=u+t;
				y[k+h/2]=u-t;
				w=w*wn;
			}
		}
	}
	if (on==-1) for (int i=0;i<len;i++) y[i].r/=(double)len;
}
const int Maxn=1e6;
complex v[Maxn*2+5],k[Maxn*2+5];
int dif[Maxn*2+5];
int ans[Maxn+5],cnt;
char str[Maxn+5];
int n;

inline void solve(int T){
	scanf("%d%s",&n,str);

	int mxLen=n*2;
	int len=1<<(int)(ceil(log(mxLen)/log(2)));

	for (int i=0;i<n;i++) {
		v[i]=complex((str[i]=='V'?1.0:0),0);
		k[i]=complex((str[n-i-1]=='K'?1.0:0),0);
	}
	for (int i=n;i<len;i++) v[i]=k[i]=complex(0,0);

	FFT(v,len,1);FFT(k,len,1);
	for (int i=0;i<len;i++) v[i]=v[i]*k[i];
	FFT(v,len,-1);
	for (int i=0;i<len;i++) dif[i]=(int)(v[i].r+0.5);

	cnt=0;
	for (int i=1;i<=n;i++){
		bool flag=true;
		for (int now=i;now<n && flag;now+=i){
			if (dif[n-1-now]>0 || dif[n-1+now]) flag=false;
		}
		if (flag) ans[++cnt]=i;
	}

	printf("%d\n",cnt);
	for (int i=1;i<=cnt;i++) printf("%d%c",ans[i],i==cnt?'\n':' ');
}

int main(){
	//freopen("in.txt","r",stdin);
	int T=0;scanf("%d",&T);
	for (int i=1;i<=T;i++) solve(i);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MX = (1 << 20);
const double pi = acos(-1);

struct base {
	double x, y;

	base(double x = 0, double y = 0) : x(x), y(y) { }
	base operator + (const base& v) { return base(x + v.x, y + v.y); }
	base operator - (const base& v) { return base(x - v.x, y - v.y); }
	base operator * (const base& v) { return base(x * v.x - y * v.y, x * v.y + y * v.x); }
	void operator /= (int d) { x /= d; y /= d; }
	double real() { return x; }
	double imag() { return y; }
	void imag(double z) { y = z; }
};

int rev[MX];
base w[MX + 1];

void init(int n) {
	int log_n = 0;
	while ((n >> log_n) > 1) log_n++;

	for (int i = 0; i < n; i++) {
		rev[i] = 0;
		for (int j = 0; j < log_n; j++)
			rev[i] |= (i >> j & 1) << (log_n - 1 - j);

		if (rev[i] < i) rev[i] = i;
	}

	w[1] = base(1, 0);
	for (int p = 0; p < log_n - 1; p++) {
		double alpha = pi / (n >> (log_n - 1 - p));
		base cur(cos(alpha), sin(alpha));
		for (int j = (1 << p); j < (2 << p); j++) {
			w[2 * j] = w[j];
			w[2 * j + 1] = w[j] * cur;
		}
	}
}

void fft(base a[], int n, bool invert) {
	for (int i = 0; i < n; i++) {
		swap(a[i], a[rev[i]]);
		if (invert) a[i].imag(-1 * a[i].imag());
	}
	for (int len = 1; len < n; len *= 2)
		for (int i = 0; i < n; i += 2 * len)
			for (int j = i, k = i + len; j < i + len; j++, k++) {
				base t = a[k] * w[k - i];
				a[k] = a[j] - t;
				a[j] = a[j] + t;
			}
	if (invert) for (int i = 0; i < n; i++) a[i] /= n;
}

char s[MX];
base a[MX], b[MX];

int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		int n;
		scanf("%d %s", &n, s);

		int N = 1;
		while (N < 2 * n) N *= 2;

		for (int i = 0; i < N; i++) a[i] = b[i] = base();

		for (int i = 0; i < n; i++) {
			if (s[i] == 'V') a[i] = base(1, 0);
			if (s[i] == 'K') b[n - 1 - i] = base(1, 0);
		}

		init(N);

		fft(a, N, false);
		fft(b, N, false);

		for (int i = 0; i < N; i++) a[i] = a[i] * b[i];

		fft(a, N, true);

		vector<int> ans;
		for (int i = 1; i <= n; i++) {
			bool ok = true;
			for (int j = i; j < n; j += i){
				if (i<n && abs(a[n - 1 - j].real()) > 0.5)
					ok = false;
				if (i==n && abs(a[n - 1 + j].real()) > 0.5)
				    ok = false;
			}

			if (ok) ans.push_back(i);
		}

		printf("%d\n", (int)ans.size());
		for (int x : ans) printf("%d ", x);
		printf("\n");
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MX = (1 << 20);
const double pi = acos(-1);

struct base {
	double x, y;

	base(double x = 0, double y = 0) : x(x), y(y) { }
	base operator + (const base& v) { return base(x + v.x, y + v.y); }
	base operator - (const base& v) { return base(x - v.x, y - v.y); }
	base operator * (const base& v) { return base(x * v.x - y * v.y, x * v.y + y * v.x); }
	void operator /= (int d) { x /= d; y /= d; }
	double real() { return x; }
	double imag() { return y; }
	void imag(double z) { y = z; }
};

int rev[MX];
base w[MX + 1];

void init(int n) {
	int log_n = 0;
	while ((n >> log_n) > 1) log_n++;

	for (int i = 0; i < n; i++) {
		rev[i] = 0;
		for (int j = 0; j < log_n; j++)
			rev[i] |= (i >> j & 1) << (log_n - 1 - j);

		if (rev[i] < i) rev[i] = i;
	}

	w[1] = base(1, 0);
	for (int p = 0; p < log_n - 1; p++) {
		double alpha = pi / (n >> (log_n - 1 - p));
		base cur(cos(alpha), sin(alpha));
		for (int j = (1 << p); j < (2 << p); j++) {
			w[2 * j] = w[j];
			w[2 * j + 1] = w[j] * cur;
		}
	}
}

void fft(base a[], int n, bool invert) {
	for (int i = 0; i < n; i++) {
		swap(a[i], a[rev[i]]);
		if (invert) a[i].imag(-1 * a[i].imag());
	}
	for (int len = 1; len < n; len *= 2)
		for (int i = 0; i < n; i += 2 * len)
			for (int j = i, k = i + len; j < i + len; j++, k++) {
				base t = a[k] * w[k - i];
				a[k] = a[j] - t;
				a[j] = a[j] + t;
			}
	if (invert) for (int i = 0; i < n; i++) a[i] /= n;
}

char s[MX];
base a[MX], b[MX];

int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		int n;
		scanf("%d %s", &n, s);

		int N = 1;
		while (N < 2 * n) N *= 2;

		for (int i = 0; i < N; i++) a[i] = b[i] = base();

		for (int i = 0; i < n; i++) {
			if (s[i] == 'V') a[i] = base(1, 0);
			if (s[i] == 'K') b[n - 1 - i] = base(1, 0);
		}

		init(N);

		fft(a, N, false);
		fft(b, N, false);

		for (int i = 0; i < N; i++) a[i] = a[i] * b[i];

		fft(a, N, true);

		vector<int> ans;
		for (int i = 1; i <= n; i++) {
			bool ok = true;
			for (int j = i; j <=i ; j += i)
				if (abs(a[n - 1 + j].real()) > 0.5 || abs(a[n - 1 - j].real()) > 0.5)
					ok = false;

			if (ok) ans.push_back(i);
		}

		printf("%d\n", (int)ans.size());
		for (int x : ans) printf("%d ", x);
		printf("\n");
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MX = (1 << 20);
const double pi = acos(-1);

struct base {
	double x, y;

	base(double x = 0, double y = 0) : x(x), y(y) { }
	base operator + (const base& v) { return base(x + v.x, y + v.y); }
	base operator - (const base& v) { return base(x - v.x, y - v.y); }
	base operator * (const base& v) { return base(x * v.x - y * v.y, x * v.y + y * v.x); }
	void operator /= (int d) { x /= d; y /= d; }
	double real() { return x; }
	double imag() { return y; }
	void imag(double z) { y = z; }
};

int rev[MX];
base w[MX + 1];

void init(int n) {
	int log_n = 0;
	while ((n >> log_n) > 1) log_n++;

	for (int i = 0; i < n; i++) {
		rev[i] = 0;
		for (int j = 0; j < log_n; j++)
			rev[i] |= (i >> j & 1) << (log_n - 1 - j);

		if (rev[i] < i) rev[i] = i;
	}

	w[1] = base(1, 0);
	for (int p = 0; p < log_n - 1; p++) {
		double alpha = pi / (n >> (log_n - 1 - p));
		base cur(cos(alpha), sin(alpha));
		for (int j = (1 << p); j < (2 << p); j++) {
			w[2 * j] = w[j];
			w[2 * j + 1] = w[j] * cur;
		}
	}
}

void fft(base a[], int n, bool invert) {
	for (int i = 0; i < n; i++) {
		swap(a[i], a[rev[i]]);
		if (invert) a[i].imag(-1 * a[i].imag());
	}
	for (int len = 1; len < n; len *= 2)
		for (int i = 0; i < n; i += 2 * len)
			for (int j = i, k = i + len; j < i + len; j++, k++) {
				base t = a[k] * w[k - i];
				a[k] = a[j] - t;
				a[j] = a[j] + t;
			}
	if (invert) for (int i = 0; i < n; i++) a[i] /= n;
}

char s[MX];
base a[MX], b[MX];

int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		int n;
		scanf("%d %s", &n, s);

		int N = 1;
		while (N < 2 * n) N *= 2;

		for (int i = 0; i < N; i++) a[i] = b[i] = base();

		for (int i = 0; i < n; i++) {
			if (s[i] == 'V') a[i] = base(1, 0);
			if (s[i] == 'K') b[n - 1 - i] = base(1, 0);
		}

		init(N);

		fft(a, N, false);
		fft(b, N, false);

		for (int i = 0; i < N; i++) a[i] = a[i] * b[i];

		fft(a, N, true);

		vector<int> ans;
		for (int i = 1; i <= n; i++) {
			bool ok = true;
			for (int j = i; j < n ; j += i)
				if (abs(a[n - 1 - j].real()) > 0.5)
					ok = false;

			if (ok) ans.push_back(i);
		}

		printf("%d\n", (int)ans.size());
		for (int x : ans) printf("%d ", x);
		printf("\n");
	}

	return 0;
}


#include <cstdio>
#include <cmath>
using namespace std;

const double PI=acos(-1.0);
struct complex{
	double r,i;
	complex(){}
	complex(double r0,double i0){r=r0;i=i0;}
	complex operator + (const complex &B){return complex(r+B.r,i+B.i);}
	complex operator - (const complex &B){return complex(r-B.r,i-B.i);}
	complex operator * (const complex &B){return complex(r*B.r-i*B.i,i*B.r+r*B.i);}
};
void change(complex y[],int len){
	for (int i=1,j=len/2;i<len-1;i++){
		if (i<j) swap(y[i],y[j]);
		int k=len/2;
		while(j>=k){
			j-=k;
			k>>=1;
		}
		if(j<k) j+=k;
	}
}
void FFT(complex y[],int len,int on){
	change(y,len);
	for (int h=2;h<=len;h<<=1){
		complex wn=complex(cos((double)on*2*PI/h),sin((double)on*2*PI/h));
		for (int j=0;j<len;j+=h){
			complex w=complex(1,0);
			for (int k=j;k<j+h/2;k++){
				complex u=y[k],t=y[k+h/2]*w;
				y[k]=u+t;
				y[k+h/2]=u-t;
				w=w*wn;
			}
		}
	}
	if (on==-1) for (int i=0;i<len;i++) y[i].r/=(double)len;
}
const int Maxn=1e6;
complex v[Maxn*2+5],k[Maxn*2+5];
int dif[Maxn*2+5];
int ans[Maxn+5],cnt;
char str[Maxn+5];
int n;

inline void solve(int T){
	scanf("%d%s",&n,str);

	int mxLen=n*2;
	int len=1<<(int)(ceil(log(mxLen)/log(2)));

	for (int i=0;i<n;i++) {
		v[i]=complex((str[i]=='V'?1.0:0),0);
		k[i]=complex((str[n-i-1]=='K'?1.0:0),0);
	}
	for (int i=n;i<len;i++) v[i]=k[i]=complex(0,0);

	FFT(v,len,1);FFT(k,len,1);
	for (int i=0;i<len;i++) v[i]=v[i]*k[i];
	FFT(v,len,-1);
	for (int i=0;i<len;i++) dif[i]=(int)(v[i].r+0.5);

	cnt=0;
	for (int i=1;i<=n;i++){
		bool flag=true;
		for (int now=i;now<n && flag;now+=i){
			if (dif[n-1-now]>0 || dif[n-1+now]>0) flag=false;
		}
		if (flag) ans[++cnt]=i;
	}

	printf("%d\n",cnt);
	for (int i=1;i<=cnt;i++) printf("%d%c",ans[i],i==cnt?'\n':' ');
}

int main(){
	//freopen("in.txt","r",stdin);
	int T=0;scanf("%d",&T);
	for (int i=1;i<=T;i++) solve(i);
	return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;

const double PI=acos(-1.0);
struct complex{
	double r,i;
	complex(){}
	complex(double r0,double i0){r=r0;i=i0;}
	complex operator + (const complex &B){return complex(r+B.r,i+B.i);}
	complex operator - (const complex &B){return complex(r-B.r,i-B.i);}
	complex operator * (const complex &B){return complex(r*B.r-i*B.i,i*B.r+r*B.i);}
};
void change(complex y[],int len){
	for (int i=1,j=len/2;i<len-1;i++){
		if (i<j) swap(y[i],y[j]);
		int k=len/2;
		while(j>=k){
			j-=k;
			k>>=1;
		}
		if(j<k) j+=k;
	}
}
void FFT(complex y[],int len,int on){
	change(y,len);
	for (int h=2;h<=len;h<<=1){
		complex wn=complex(cos((double)on*2*PI/h),sin((double)on*2*PI/h));
		for (int j=0;j<len;j+=h){
			complex w=complex(1,0);
			for (int k=j;k<j+h/2;k++){
				complex u=y[k],t=y[k+h/2]*w;
				y[k]=u+t;
				y[k+h/2]=u-t;
				w=w*wn;
			}
		}
	}
	if (on==-1) for (int i=0;i<len;i++) y[i].r/=(double)len;
}
const int Maxn=1e6;
complex v[Maxn*2+5],k[Maxn*2+5];
int dif[Maxn*2+5];
int ans[Maxn+5],cnt;
char str[Maxn+5];
int n;

inline void solve(int T){
	scanf("%d%s",&n,str);

	int mxLen=n*2;
	int len=1<<(int)(ceil(log(mxLen)/log(2)));

	for (int i=0;i<n;i++) {
		v[i]=complex((str[i]=='V'?1.0:0),0);
		k[i]=complex((str[n-i-1]=='K'?1.0:0),0);
	}
	for (int i=n;i<len;i++) v[i]=k[i]=complex(0,0);

	FFT(v,len,1);FFT(k,len,1);
	for (int i=0;i<len;i++) v[i]=v[i]*k[i];
	FFT(v,len,-1);
	for (int i=0;i<len;i++) {
		dif[i]=(int)(v[i].r+0.5);
		//printf("#:%d=%d\n",i,dif[i]);
	}

	cnt=0;
	for (int i=1;i<=n;i++){
		bool flag=true;
		for (int now=i;now<n && flag;now+=i){
			if (dif[n-1-now]>0) flag=false;
		}
		if (flag) ans[++cnt]=i;
	}

	printf("%d\n",cnt);
	for (int i=1;i<=cnt;i++) printf("%d%c",ans[i],i==cnt?'\n':' ');
}

int main(){
	//freopen("in.txt","r",stdin);
	int T=0;scanf("%d",&T);
	for (int i=1;i<=T;i++) solve(i);
	return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;

const double PI=acos(-1.0);
struct complex{
	double r,i;
	complex(){}
	complex(double r0,double i0){r=r0;i=i0;}
	complex operator + (const complex &B){return complex(r+B.r,i+B.i);}
	complex operator - (const complex &B){return complex(r-B.r,i-B.i);}
	complex operator * (const complex &B){return complex(r*B.r-i*B.i,i*B.r+r*B.i);}
};
void change(complex y[],int len){
	for (int i=1,j=len/2;i<len-1;i++){
		if (i<j) swap(y[i],y[j]);
		int k=len/2;
		while(j>=k){
			j-=k;
			k>>=1;
		}
		if(j<k) j+=k;
	}
}
void FFT(complex y[],int len,int on){
	change(y,len);
	for (int h=2;h<=len;h<<=1){
		complex wn=complex(cos((double)on*2*PI/h),sin((double)on*2*PI/h));
		for (int j=0;j<len;j+=h){
			complex w=complex(1,0);
			for (int k=j;k<j+h/2;k++){
				complex u=y[k],t=y[k+h/2]*w;
				y[k]=u+t;
				y[k+h/2]=u-t;
				w=w*wn;
			}
		}
	}
	if (on==-1) for (int i=0;i<len;i++) y[i].r/=(double)len;
}
const int Maxn=1e6;
complex v[Maxn*2+5],k[Maxn*2+5];
int dif[Maxn*2+5];
int ans[Maxn+5],cnt;
char str[Maxn+5];
int n;

inline void solve(int T){
	scanf("%d%s",&n,str);

	int mxLen=n*2;
	int len=1<<(int)(ceil(log(mxLen)/log(2)));

	for (int i=0;i<n;i++) {
		v[i]=complex((str[i]=='V'?1.0:0),0);
		k[i]=complex((str[n-i-1]=='K'?1.0:0),0);
	}
	for (int i=n;i<len;i++) v[i]=k[i]=complex(0,0);

	FFT(v,len,1);FFT(k,len,1);
	for (int i=0;i<len;i++) v[i]=v[i]*k[i];
	FFT(v,len,-1);
	for (int i=0;i<len;i++) dif[i]=(int)(v[i].r+0.5);

	cnt=0;
	for (int i=1;i<=n;i++){
		bool flag=true;
		for (int now=i;now<n && flag;now+=i){
			if (dif[n-1-now]>0 || dif[n-1+now]>0) flag=false;
		}
		if (flag) ans[++cnt]=i;
	}

	printf("%d\n",cnt);
	for (int i=1;i<=cnt;i++) printf("%d%c",ans[i],i==cnt?'\n':' ');
}

int main(){
	//freopen("in.txt","r",stdin);
	int T=0;scanf("%d",&T);
	for (int i=1;i<=T;i++) solve(i);
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>
//
using namespace std;

#define ll long long
#define MOD 998244353
#define mul(a, b) (((ll)(a) * (ll)(b)) % MOD)

int fpow(int base, int exponent)
{
    int ans = 1;
    int cur = base;
    while (exponent) {
        if (exponent & 1) ans = mul(ans, cur);
        cur = mul(cur, cur); exponent >>= 1;
    }
    return ans;
}

int siz;
int rev[1050000];
int n;

void prentt(int s)
{
    siz = 1;
    while (siz < s * 2) siz <<= 1;
    for (int i = 0; i < siz; i++) {
        rev[i] = (i & 1 ? rev[i - 1] | (siz >> 1) : rev[i >> 1] >> 1);
    }
}

void ntt(int* poly, bool inv)
{
    for (int i = 0; i < siz; i++) {
        if (i < rev[i]) {
            int t = poly[i]; poly[i] = poly[rev[i]]; poly[rev[i]] = t;
        }
    }
    for (int csiz = 2; csiz <= siz; csiz <<= 1) {
        int root = fpow(3, (MOD - 1) / csiz);
        if (inv) root = fpow(root, MOD - 2);
        for (int st = 0; st < siz; st += csiz) {
            int curr = 1;
            for (int cur = st; cur < st + (csiz >> 1); cur++) {
                int tmp = mul(curr, poly[cur + (csiz >> 1)]);
                poly[cur + (csiz >> 1)] = poly[cur] - tmp + MOD;
                if (poly[cur + (csiz >> 1)] >= MOD) poly[cur + (csiz >> 1)] -= MOD;
                poly[cur] = poly[cur] + tmp;
                if (poly[cur] >= MOD) poly[cur] -= MOD;
                curr = mul(curr, root);
            }
        }
    }
    if (inv) {
        int invs = fpow(siz, MOD - 2);
        for (int i = 0; i < siz; i++) poly[i] = mul(poly[i], invs);
    }
}

int a[1050000];
int b[1050000];
int a2[1050000];
int b2[1050000];
int a3[1050000];
int b3[1050000];
int ans[1050000];
char s[1050000];

void work(void)
{
    scanf("%d", &n);
    scanf("%s", s);
    for (int i = 0; i < n; i++) {
        a[i] = (s[i] == 'V' ? 1 : (s[i] == 'K' ? 2 : 0));
        b[n-i-1] = a[i];
    }
    for (int i = 0; i < n; i++) {
        a2[i] = mul(a[i], a[i]);
        a3[i] = mul(a2[i], a[i]);
        b2[i] = mul(b[i], b[i]);
        b3[i] = mul(b2[i], b[i]);
    }
    prentt(n);
    ntt(a, false);
    ntt(b, false);
    ntt(a2, false);
    ntt(b2, false);
    ntt(a3, false);
    ntt(b3, false);
    for (int i = 0; i < siz; i++) {
        ll ansv = (ll)a3[i] * (ll)b[i] - 2LL * (ll)a2[i] * (ll)b2[i]
            + (ll)a[i] * (ll)b3[i];
        ans[i] = ((ansv % MOD) + MOD) % MOD;
    }
    ntt(ans, true);
    vector<int> output;
    for (int i = 1; i <= n; i++) {
        bool good = true;
        for (int j = i; j <= n; j += i) {
            if (j != n && ans[n - j - 1]) good = false;
        }
        if (good) output.push_back(i);
    }
    printf("%d\n", (int)output.size());
    for (int i = 0; i < output.size(); i++) {
        printf("%d ", output[i]);
    }
    printf("\n");
    for (int i = 0; i < siz; i++) {
        a[i] = b[i] = a2[i] = b2[i] = a3[i] = b3[i] = 0;
    }
}

int main()
{
    int T;
    scanf("%d", &T);
    for (int i = 1; i <= T; i++) {
        work();
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

#define ll long long
#define MOD 998244353
#define mul(a, b) (((ll)(a) * (ll)(b)) % MOD)

int fpow(int base, int exponent)
{
    int ans = 1;
    int cur = base;
    while (exponent) {
        if (exponent & 1) ans = mul(ans, cur);
        cur = mul(cur, cur); exponent >>= 1;
    }
    return ans;
}

int siz;
int rev[1050000];
int n;

void prentt(int s)
{
    siz = 1;
    while (siz < s * 2) siz <<= 1;
    for (int i = 0; i < siz; i++) {
        rev[i] = (i & 1 ? rev[i - 1] | (siz >> 1) : rev[i >> 1] >> 1);
    }
}

void ntt(int* poly, bool inv)
{
    for (int i = 0; i < siz; i++) {
        if (i < rev[i]) {
            int t = poly[i]; poly[i] = poly[rev[i]]; poly[rev[i]] = t;
        }
    }
    for (int csiz = 2; csiz <= siz; csiz <<= 1) {
        int root = fpow(3, (MOD - 1) / csiz);
        if (inv) root = fpow(root, MOD - 2);
        for (int st = 0; st < siz; st += csiz) {
            int curr = 1;
            for (int cur = st; cur < st + (csiz >> 1); cur++) {
                int tmp = mul(curr, poly[cur + (csiz >> 1)]);
                poly[cur + (csiz >> 1)] = poly[cur] - tmp + MOD;
                if (poly[cur + (csiz >> 1)] >= MOD) poly[cur + (csiz >> 1)] -= MOD;
                poly[cur] = poly[cur] + tmp;
                if (poly[cur] >= MOD) poly[cur] -= MOD;
                curr = mul(curr, root);
            }
        }
    }
    if (inv) {
        int invs = fpow(siz, MOD - 2);
        for (int i = 0; i < siz; i++) poly[i] = mul(poly[i], invs);
    }
}

int a[1050000];
int b[1050000];
int a2[1050000];
int b2[1050000];
int a3[1050000];
int b3[1050000];
int ans[1050000];
char s[1050000];

void work(void)
{
    scanf("%d", &n);
    scanf("%s", s);
    for (int i = 0; i < n; i++) {
        a[i] = (s[i] == 'V' ? 1 : (s[i] == 'K' ? 2 : 0));
        b[n-i-1] = a[i];
    }
    for (int i = 0; i < n; i++) {
        a2[i] = mul(a[i], a[i]);
        a3[i] = mul(a2[i], a[i]);
        b2[i] = mul(b[i], b[i]);
        b3[i] = mul(b2[i], b[i]);
    }
    prentt(n);
    ntt(a, false);
    ntt(b, false);
    ntt(a2, false);
    ntt(b2, false);
    ntt(a3, false);
    ntt(b3, false);
    for (int i = 0; i < siz; i++) {
        ll ansv = (ll)a3[i] * (ll)b[i] - 2LL * (ll)a2[i] * (ll)b2[i]
            + (ll)a[i] * (ll)b3[i];
        ans[i] = ((ansv % MOD) + MOD) % MOD;
    }
    ntt(ans, true);
    vector<int> output;
    for (int i = 1; i <= n; i++) {
        bool good = true;
        for (int j = i; j <= n; j += i) {
            if (j != n && ans[n - j - 1]) good = false;
        }
        if (good) output.push_back(i);
    }
    printf("%d\n", (int)output.size());
    for (int i = 0; i < output.size(); i++) {
        printf("%d ", output[i]);
    }
    printf("\n");
    for (int i = 0; i < siz; i++) {
        a[i] = b[i] = a2[i] = b2[i] = a3[i] = b3[i] = 0;
    }
}

int main()
{
    int T;
    scanf("%d", &T);
    for (int i = 1; i <= T; i++) {
        work();
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>

using std::vector;
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(int i = a; i < (b); ++i)

#define MAX (6 * 100 * 1000)

typedef long long ll;

const ll mod = (119 << 23) + 1, root = 3; // = 998244353

ll modpow(ll a, ll e) {
if (e == 0) return 1;
ll x = modpow(a * a % mod, e >> 1);
return e & 1 ? x * a % mod : x;
}

// For p < 2ˆ30 there i s also e . g . (5 << 25, 3) , (7 << 26, 3) ,
// (479 << 21, 3) and (483 << 21, 5) . The l a s t two are > 10ˆ9.
typedef vector<ll> vl;
void ntt(ll* x, ll* temp, ll* roots, int N, int skip) {
if (N == 1) return;
int n2 = N/2;
ntt(x
, temp, roots, n2, skip*2);
ntt(x+skip, temp, roots, n2, skip*2);
rep(i,0,N) temp[i] = x[i*skip];
rep(i,0,n2) {
ll s = temp[2*i], t = temp[2*i+1] * roots[skip*i];
x[skip*i] = (s + t) % mod; x[skip*(i+n2)] = (s - t) % mod;
}
}
void ntt(vl& x, bool inv = false) {
ll e = modpow(root, (mod-1) / sz(x));
if (inv) e = modpow(e, mod-2);
vl roots(sz(x), 1), temp = roots;
rep(i,1,sz(x)) roots[i] = roots[i-1] * e % mod;
ntt(&x[0], &temp[0], &roots[0], sz(x), 1);
}
vl conv(vl a, vl b) {
int s = sz(a) + sz(b) - 1; if (s <= 0) return {};
int L = s > 1 ? 32 - __builtin_clz(s - 1) : 0, n = 1 << L;
if (s <= 200) { // ( factor 10 optimization for | a | , | b | = 10)
vl c(s);
rep(i,0,sz(a)) rep(j,0,sz(b))
c[i + j] = (c[i + j] + a[i] * b[j]) % mod;
return c;
}
a.resize(n); ntt(a);
b.resize(n); ntt(b);
vl c(n); ll d = modpow(n, mod-2);
rep(i,0,n) c[i] = a[i] * b[i] % mod * d % mod;
ntt(c, true); c.resize(s); return c;
}

int main(void)
{
  std::vector<long long> p, q, p_times_q;

  int t;
  for(scanf("%d", &t); t --;)
  {
    int n;
    char s[1 + MAX + 1];

    s[0] = 0;
    scanf("%d %s", &n, s);

    p.clear();
    q.clear();
    p_times_q.clear();

    for(int i = 0; i < n; i ++)
    {
      p.push_back(s[i] == 'V');
      q.push_back(s[n - 1 - i] == 'K');
    }

    p_times_q = conv(p, q);

    bool exists_conflicting_pair[MAX];
    memset(exists_conflicting_pair, 0, sizeof(bool) * n);

    for(int i = 0; i < 2 * n; i ++)
    {
      if(p_times_q[i] != 0)
      {
        int x = (i + 1 - n);
        if(abs(x) < n)
        {
          exists_conflicting_pair[abs(x)] = true;
        }
      }
    }

    /*for(int i = 0; i <= 2 * n; i ++)
    {
      fprintf(stderr, "%d%c", p[i], (i == 2 * n) ? '\n' : ' ');
    }

    for(int i = 0; i <= 2 * n; i ++)
    {
      fprintf(stderr, "%d%c", q[i], (i == 2 * n) ? '\n' : ' ');
    }

    for(int i = 0; i <= 2 * n; i ++)
    {
      fprintf(stderr, "%d%c", p_times_q[i], (i == 2 * n) ? '\n' : ' ');
    }*/

    int k = 0;
    int answers[MAX];

    for(int i = 1; i < n; i ++)
    {
      bool okay = true;
      for(int j = i; okay && j < n; j += i)
      {
        okay &= !exists_conflicting_pair[j];
      }

      if(okay)
      {
        answers[k ++] = i;
      }
    }

    answers[k ++] = n;

    printf("%d\n", k);
    for(int i = 0; i < k; i ++)
    {
      printf("%d%c", answers[i], (i == k - 1) ? '\n' : ' ');
    }
  }

  return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>

#define MAX (6 * 100 * 1000)

int main(void)
{
  int t;
  for(scanf("%d", &t); t --;)
  {
    int n;
    char s[1 + MAX + 1];

    s[0] = 0;
    scanf("%d %s", &n, s);

    int p[MAX];
    int q[MAX];
    int p_times_q[2 * MAX - 1];

    memset(p, 0, sizeof(int) * n);
    memset(q, 0, sizeof(int) * n);
    memset(p_times_q, 0, sizeof(int) * (2 * n - 1));

    for(int i = 0; i < n; i ++)
    {
      p[i] = (s[i] == 'V');
      q[i] = (s[n - 1 - i] == 'K');
    }

    for(int i = 0; i < n; i ++)
    {
      for(int j = 0; j < n; j ++)
      {
        p_times_q[i + j] += p[i] * q[j];
      }
    }

    bool exists_conflicting_pair[MAX];
    memset(exists_conflicting_pair, 0, sizeof(bool) * n);

    for(int i = 0; i < 2 * n; i ++)
    {
      if(p_times_q[i] > 0)
      {
        int x = (i + 1 - n);
        if(abs(x) < n)
        {
          exists_conflicting_pair[abs(x)] = true;
        }
      }
    }

    /*for(int i = 0; i <= 2 * n; i ++)
    {
      fprintf(stderr, "%d%c", p[i], (i == 2 * n) ? '\n' : ' ');
    }

    for(int i = 0; i <= 2 * n; i ++)
    {
      fprintf(stderr, "%d%c", q[i], (i == 2 * n) ? '\n' : ' ');
    }

    for(int i = 0; i <= 2 * n; i ++)
    {
      fprintf(stderr, "%d%c", p_times_q[i], (i == 2 * n) ? '\n' : ' ');
    }*/

    int k = 0;
    int answers[MAX];

    for(int i = 1; i < n; i ++)
    {
      bool okay = true;
      for(int j = i; okay && j < n; j += i)
      {
        okay &= !exists_conflicting_pair[j];
      }

      if(okay)
      {
        answers[k ++] = i;
      }
    }

    answers[k ++] = n;

    printf("%d\n", k);
    for(int i = 0; i < k; i ++)
    {
      printf("%d%c", answers[i], (i == k - 1) ? '\n' : ' ');
    }
  }

  return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>

using std::vector;
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(int i = a; i < (b); ++i)

#define MAX (6 * 100 * 1000)

typedef long long ll;

const ll mod = (119 << 23) + 1, root = 3; // = 998244353

ll modpow(ll a, ll e) {
if (e == 0) return 1;
ll x = modpow(a * a % mod, e >> 1);
return e & 1 ? x * a % mod : x;
}

// For p < 2ˆ30 there i s also e . g . (5 << 25, 3) , (7 << 26, 3) ,
// (479 << 21, 3) and (483 << 21, 5) . The l a s t two are > 10ˆ9.
typedef vector<ll> vl;
void ntt(ll* x, ll* temp, ll* roots, int N, int skip) {
if (N == 1) return;
int n2 = N/2;
ntt(x
, temp, roots, n2, skip*2);
ntt(x+skip, temp, roots, n2, skip*2);
rep(i,0,N) temp[i] = x[i*skip];
rep(i,0,n2) {
ll s = temp[2*i], t = temp[2*i+1] * roots[skip*i];
x[skip*i] = (s + t) % mod; x[skip*(i+n2)] = (s - t) % mod;
}
}
void ntt(vl& x, bool inv = false) {
ll e = modpow(root, (mod-1) / sz(x));
if (inv) e = modpow(e, mod-2);
vl roots(sz(x), 1), temp = roots;
rep(i,1,sz(x)) roots[i] = roots[i-1] * e % mod;
ntt(&x[0], &temp[0], &roots[0], sz(x), 1);
}
vl conv(vl a, vl b) {
int s = sz(a) + sz(b) - 1; if (s <= 0) return {};
int L = s > 1 ? 32 - __builtin_clz(s - 1) : 0, n = 1 << L;
if (s <= 200) { // ( factor 10 optimization for | a | , | b | = 10)
vl c(s);
rep(i,0,sz(a)) rep(j,0,sz(b))
c[i + j] = (c[i + j] + a[i] * b[j]) % mod;
return c;
}
a.resize(n); ntt(a);
b.resize(n); ntt(b);
vl c(n); ll d = modpow(n, mod-2);
rep(i,0,n) c[i] = a[i] * b[i] % mod * d % mod;
ntt(c, true); c.resize(s); return c;
}

int main(void)
{
  std::vector<long long> p, q, p_times_q;

  int t;
  for(scanf("%d", &t); t --;)
  {
    int n;
    char s[1 + MAX + 1];

    s[0] = 0;
    scanf("%d %s", &n, s);

    p.clear();
    q.clear();
    p_times_q.clear();

    for(int i = 0; i < n; i ++)
    {
      p.push_back(s[i] == 'V');
      q.push_back(s[n - 1 - i] == 'K');
    }

    p_times_q = conv(p, q);

    bool exists_conflicting_pair[MAX];
    memset(exists_conflicting_pair, 0, sizeof(bool) * n);

    for(int i = 0; i < 2 * n; i ++)
    {
      p_times_q[i] %= mod;
      if(p_times_q[i] != 0)
      {
        int x = (i + 1 - n);
        if(abs(x) < n)
        {
          exists_conflicting_pair[abs(x)] = true;
        }
      }
    }

    /*for(int i = 0; i <= 2 * n; i ++)
    {
      fprintf(stderr, "%d%c", p[i], (i == 2 * n) ? '\n' : ' ');
    }

    for(int i = 0; i <= 2 * n; i ++)
    {
      fprintf(stderr, "%d%c", q[i], (i == 2 * n) ? '\n' : ' ');
    }

    for(int i = 0; i <= 2 * n; i ++)
    {
      fprintf(stderr, "%d%c", p_times_q[i], (i == 2 * n) ? '\n' : ' ');
    }*/

    int k = 0;
    int answers[MAX];

    for(int i = 1; i < n; i ++)
    {
      bool okay = true;
      for(int j = i; okay && j < n; j += i)
      {
        okay &= !exists_conflicting_pair[j];
      }

      if(okay)
      {
        answers[k ++] = i;
      }
    }

    answers[k ++] = n;

    printf("%d\n", k);
    for(int i = 0; i < k; i ++)
    {
      printf("%d%c", answers[i], (i == k - 1) ? '\n' : ' ');
    }
  }

  return 0;
}