#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long t, n;
  string s1, s2;
  vector<long long> v;
  cin >> t;
  while (t--) {
    v.clear();
    cin >> n;
    cin >> s1 >> s2;
    for (int i = 0; i < n; i++) {
      if (s1[i] != s2[i]) {
        if (i == 0) {
          v.push_back(1);
        } else {
          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 << "\n";
  }
  return 0;
}
