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