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