#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k = 0;
  cin >> n;
  string a, b;
  cin >> a >> b;
  vector<long long> v;
  for (long long i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      k++;
      v.push_back(i + 1);
    }
  }
  cout << 3 * k << " ";
  for (long long i = 0; i < k; i++) {
    cout << v[i] << " 1 " << v[i] << " ";
  }
  cout << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
