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