#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
int n;
string a, b;
void solve() {
  cin >> n;
  cin >> a >> b;
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    if (a[i] != b[i]) {
      ans.push_back(i + 1);
      ans.push_back(1);
      ans.push_back(i + 1);
    }
  }
  cout << ans.size() << " ";
  for (auto& it : ans) cout << it << " ";
  cout << '\n';
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int tests;
  cin >> tests;
  for (int i = 0; i < tests; ++i) {
    solve();
  }
  return 0;
}
