#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int MAXN = 111111;
void solution() {
  int n;
  cin >> n;
  string a, b;
  vector<int> c;
  cin >> a >> b;
  int ans = 0;
  for (int i = (0); i < (n); ++i) {
    if (a[i] != b[i]) {
      ans += 3;
      c.push_back(i + 1);
      c.push_back(1);
      c.push_back(i + 1);
    }
  }
  cout << ans << " ";
  for (auto x : c) {
    cout << x << " ";
  }
  cout << '\n';
  c.clear();
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solution();
  }
}
