#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
void _print(int a) { cerr << a; }
void _print(bool a) { cerr << a; }
void _print(long long a) { cerr << a; }
template <class T>
void _print(std::vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(std::set<T> s) {
  cerr << "[ ";
  for (T i : s) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(std::multiset<T> s) {
  cerr << "[ ";
  for (T i : s) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
vector<long long> sieve(int n) {
  int* arr = new int[n + 1]();
  vector<long long> vect;
  for (int i = 2; i <= n; i++)
    if (arr[i] == 0) {
      vect.push_back(i);
      for (int j = 2 * i; j <= n; j += i) arr[j] = 1;
    }
  return vect;
}
long long mod_add(long long a, long long b, long long M) {
  a = a % M;
  b = b % M;
  return (((a + b) % M) + M) % M;
}
long long mod_mul(long long a, long long b, long long M) {
  a = a % M;
  b = b % M;
  return (((a * b) % M) + M) % M;
}
long long mod_sub(long long a, long long b, long long M) {
  a = a % M;
  b = b % M;
  return (((a - b) % M) + M) % M;
}
int main() {
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    int r = (int)a.size();
    if (a == b) {
      cout << 0 << "\n";
      continue;
    }
    long long ans = 0;
    for (int i = 0; i < r; i++)
      if (a[i] != b[i]) ans++;
    cout << 3 * ans << " ";
    for (int i = r - 1; i >= 0; i--) {
      if (a[i] != b[i]) cout << i + 1 << " 1 " << i + 1 << " ";
    }
    cout << "\n";
  }
}
