#include <bits/stdc++.h>
const long long INF = 1e18;
const long long N = 2e5 + 50;
using namespace std;
vector<long long> prime, g[N];
long long n, l, m, a[N], d[N];
long long POWER(long long base, long long expo) {
  long long ret = 1;
  while (expo) {
    if (expo & 1) ret = ret * base;
    expo >>= 1;
    base = base * base;
  }
  return ret;
}
void SOE(long long n) {
  bool isPrime[n + 1];
  memset(isPrime, true, sizeof(isPrime));
  for (long long p = 2; p <= n; p++) {
    if (isPrime[p]) {
      for (long long i = p * p; i <= n; i += p) isPrime[i] = false;
    }
  }
  for (long long i = 2; i <= n; i++) {
    if (isPrime[i]) prime.push_back(i);
  }
}
int main() {
  long long t = 1;
  cin >> t;
  while (t--) {
    cin >> n;
    string a, b;
    cin >> a >> b;
    vector<long long> v;
    for (long long i = n - 1; i >= 0; i--) {
      if (a[i] != b[i]) {
        v.push_back(i + 1);
        v.push_back(1);
        v.push_back(i + 1);
      }
    }
    cout << v.size() << " ";
    for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
    cout << endl;
  }
  return 0;
}
