#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long int n) {
  if (n <= 1) return 0;
  for (long long int i = 2; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
long long int min(long long int a, long long int b) {
  if (a > b)
    return b;
  else
    return a;
}
long long int max(long long int a, long long int b) {
  if (a > b)
    return a;
  else
    return b;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a == b) return a;
  if (a > b) return gcd(a - b, b);
  return gcd(a, b - a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    vector<long long int> v;
    for (long long int i = 0; i < n; 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 int i = 0; i < v.size(); i++) cout << v[i] << " ";
    cout << "\n";
  }
}
