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