#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string a, b;
  cin >> a;
  cin >> b;
  vector<int> prf;
  if (a[0] != b[0]) prf.push_back(1);
  for (int i = 1; i < n; ++i) {
    if (a[i] != b[i]) {
      prf.push_back(i + 1);
      prf.push_back(1);
      prf.push_back(i + 1);
    }
  }
  cout << prf.size() << " ";
  for (auto it : prf) cout << it << " ";
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
