#include <bits/stdc++.h>
using namespace std;
bool pr(int n) {
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int isPow2(int a) { return !(a & (a - 1)); }
int main() {
  int tests;
  cin >> tests;
  while (tests--) {
    int n;
    cin >> n;
    string s;
    string s1;
    cin >> s;
    cin >> s1;
    long long count = 0;
    int j = 0;
    vector<int> answ(3 * n);
    if (s[0] != s1[0]) {
      count++;
      answ[j] = 1;
      j++;
    }
    for (int i = 1; i < n; i++) {
      if (s[i] != s1[i]) {
        count += 3;
        answ[j] = i + 1;
        j++;
        answ[j] = 1;
        j++;
        answ[j] = i + 1;
        j++;
      }
    }
    cout << count << ' ';
    if (count != 0)
      for (int i = 0; i < j; i++) cout << answ[i] << ' ';
    cout << endl;
  }
}
