#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
int n;
char A[MAXN + 10], B[MAXN + 10];
vector<int> solve() {
  vector<int> res;
  for (int i = 0; i < n; i++) {
    if (A[i] == B[i]) continue;
    res.push_back(i);
    if (i > 0) {
      res.push_back(0);
      res.push_back(i);
    }
  }
  return res;
}
int main() {
  int T;
  scanf("%d", &T);
  for (int cs = 1; cs <= T; cs++) {
    scanf("%d%s%s", &n, A, B);
    auto res = solve();
    printf("%d", (int)res.size());
    for (int p : res) {
      printf(" %d", p + 1);
    }
    printf("\n");
  }
}
