#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
void solve() {
  string s1, s2;
  int n;
  cin >> n;
  cin >> s1 >> s2;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    if (!(i & 1)) {
      v.push_back(i / 2);
    } else {
      v.push_back(n - 1 - i / 2);
    }
  }
  reverse(s2.begin(), s2.end());
  vector<int> ans;
  int tr = 0;
  for (int i = 0; i < n; i++) {
    if ((s2[i] == s1[v[i]]) ^ tr) {
      ans.push_back(0);
    }
    ans.push_back(n - 1 - i);
    tr ^= 1;
  }
  cout << ans.size() << ' ';
  for (auto &i : ans) {
    cout << i + 1 << ' ';
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int c = 1;
  int t;
  if (!c) {
    t = 1;
  } else {
    cin >> t;
  }
  while (t--) {
    solve();
  }
}
