#include <bits/stdc++.h>
using namespace std;
void sol() {
  long long n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  vector<long long> res;
  for (long long i = 0; i < n; i++) {
    long long val = i / 2;
    if (i % 2 == 1) {
      val = n - (i + 1) / 2;
    }
    if ((a[val] == b[n - i - 1] && i % 2 == 0) ||
        (a[val] != b[n - i - 1] && i % 2 == 1)) {
      res.push_back(1);
    }
    res.push_back(n - i);
  }
  cout << res.size() << " ";
  for (auto x : res) {
    cout << x << " ";
  }
  cout << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t = 1;
  cin >> t;
  while (t--) {
    sol();
  }
}
