#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 10;
void solve() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  vector<int> fc;
  int i = 0, j = n - 1;
  while (i <= j) {
    fc.push_back(i);
    if (j != i) fc.push_back(j);
    i++;
    j--;
  }
  j = 0;
  int f = 0;
  vector<int> ans;
  for (int i = n - 1; i >= 0; i--) {
    char x = a[fc[j]];
    if (f % 2) {
      if (x == '1')
        x = '0';
      else
        x = '1';
    }
    if (x != b[i]) {
      ans.push_back(i + 1);
      f++;
    } else {
      ans.push_back(0 + 1);
      ans.push_back(i + 1);
      f++;
    }
    j++;
  }
  cout << ans.size() << ' ';
  for (auto x : ans) {
    cout << x << " ";
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
}
