#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  for (long long int x = 0; x < t; x++) {
    long long int n;
    cin >> n;
    vector<bool> a(n);
    vector<bool> b(n);
    for (long long int i = 0; i < n; i++) {
      char x;
      cin >> x;
      if (x == '1') {
        a[i] = true;
      } else {
        a[i] = false;
      }
    }
    for (long long int i = 0; i < n; i++) {
      char x;
      cin >> x;
      if (x == '1') {
        b[i] = true;
      } else {
        b[i] = false;
      }
    }
    vector<long long int> ans;
    long long int ptrTop = n - 1;
    long long int ptrBot = 0;
    bool useBot = true;
    for (long long int i = n - 1; i >= 0; i--) {
      long long int ptr;
      if (useBot) {
        ptr = ptrBot;
        ptrBot++;
      } else {
        ptr = ptrTop;
        ptrTop--;
      }
      useBot = !useBot;
      if ((a[ptr] ^ useBot) == b[i]) {
        ans.push_back(1);
      }
      ans.push_back(i + 1);
    }
    cout << ((int)(ans).size()) << " ";
    for (long long int j = 0; j < ((int)(ans).size()); j++) {
      cout << ans[j] << " ";
    }
    cout << endl;
  }
  return 0;
}
