#include <bits/stdc++.h>
using namespace std;
long long int start_up() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  return 0;
}
long long int static r = start_up();
void solve() {
  long long int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  vector<long long int> v;
  for (long long int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      v.push_back(i + 1);
      v.push_back(1);
      v.push_back(i + 1);
    }
  }
  cout << v.size() << " ";
  for (auto i : v) {
    cout << i << " ";
  }
  cout << endl;
}
signed main() {
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
