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