#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    string a, b;
    cin >> n >> a >> b;
    vector<int> oper;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        oper.push_back(i + 1);
        oper.push_back(1);
        oper.push_back(i + 1);
      }
    }
    cout << oper.size();
    for (auto x : oper) {
      cout << " " << x;
    }
    cout << endl;
  }
}
