#include <bits/stdc++.h>
const int N = 500100;
int n, stack[N], top, list[N], tot;
char s[N];
void solve() {
  scanf("%d%s", &n, s);
  tot = 0;
  for (int k = 1; k < n; k++) {
    for (int i = 0, j = k; j < n; i++, j++) {
      if (s[i] != s[j]) {
        if (s[i] == '?')
          s[i] = s[j], stack[++top] = i;
        else if (s[j] == '?')
          s[j] = s[i], stack[++top] = j;
        else
          break;
      }
      if (j == n - 1) list[++tot] = k;
    }
    while (top) s[stack[top--]] = '?';
  }
  list[++tot] = n;
  printf("%d\n", tot);
  for (int i = 1; i <= tot; i++) printf("%d ", list[i]);
  printf("\n");
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) solve();
  return 0;
}
