#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string src, dest;
    cin >> src >> dest;
    vector<long long> opr;
    for (long long i = 0; i < n; i++) {
      if (src[i] != dest[i]) {
        opr.push_back(i + 1);
        opr.push_back(1);
        opr.push_back(i + 1);
      }
    }
    cout << opr.size() << " ";
    for (auto it : opr) cout << it << " ";
    cout << "\n";
  }
}
