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