#include <bits/stdc++.h>
#pragma GCC optimize("ofsat")
#pragma GCC target("avx,avx2,fma")
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int x;
  cin >> x;
  while (x--) {
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    vector<int> v;
    for (long long int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        v.push_back(i + 1);
        v.push_back(1);
        v.push_back(i + 1);
      }
    }
    cout << (int)v.size() << " ";
    for (long long int i = 0; i < (int)v.size(); i++) {
      cout << v[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
