#include <bits/stdc++.h>
using namespace std;
void Inp_Out() {}
void speed_up() {
  ios::sync_with_stdio(0);
  cin.tie(0);
}
int main() {
  speed_up();
  Inp_Out();
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    long long i;
    std::vector<long long> v;
    for (i = 0; i < n; i += 1) {
      if (s1[i] != s2[i]) {
        v.push_back(i + 1);
        v.push_back(1);
        v.push_back(i + 1);
      }
    }
    cout << v.size() << " ";
    for (auto i : v) cout << i << " ";
    cout << "\n";
  }
}
