#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 9;
const long long mod = 1e9 + 7;
const long long maxn = 2e5 + 8;
long long n, m;
void solve() {
  long long i, j;
  vector<long long> ans;
  string a, b;
  cin >> n >> a >> b;
  for (i = 0; i < n; i++)
    if (a[i] != b[i]) {
      long long idx = i + 1;
      if (idx == 1)
        ans.push_back(idx);
      else {
        ans.push_back(idx);
        ans.push_back(1);
        ans.push_back(idx);
      }
    }
  if (ans.size() == 0)
    cout << "0" << endl;
  else {
    cout << ans.size() << " ";
    for (i = 0; i < ans.size(); i++)
      cout << ans[i] << " \n"[i == ans.size() - 1];
  }
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
