#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  char a[1123], b[1123];
  vector<int> ops;
  scanf("%d", &t);
  while (t--) {
    ops.clear();
    scanf("%d", &n);
    scanf(" %s", a);
    scanf(" %s", b);
    for (int i = 0; i < n; ++i) {
      if (a[i] != b[i]) {
        ops.push_back(i + 1);
        ops.push_back(1);
        ops.push_back(i + 1);
      }
    }
    printf("%d ", (int)ops.size());
    for (int i = 0; i < ops.size(); ++i) printf("%d ", ops[i]);
    puts("");
  }
  return 0;
}
