#include <bits/stdc++.h>
using namespace std;
int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    int t;
    string x, y;
    cin >> t >> x >> y;
    vector<int> v(0);
    for (int i = 0; i < t; ++i) {
      if (x[i] != y[i]) {
        v.push_back(i + 1);
        v.push_back(1);
        v.push_back(i + 1);
      }
    }
    cout << v.size() << ' ';
    for (int z : v) cout << z << ' ';
    cout << '\n';
  }
}
