#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, q, a, b, flag = 0, x;
    vector<int> ans;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    for (int j = 1; j < n; j++) {
      if (s1[j] != s2[j]) {
        ans.push_back(j + 1);
      }
    }
    if (s1[0] != s2[0]) {
      cout << 3 * ans.size() + 1 << "\n";
      cout << "1 ";
      for (auto x : ans) {
        cout << x << " 1 " << x << " ";
      }
    } else {
      cout << 3 * ans.size() << "\n";
      for (auto x : ans) {
        cout << x << " 1 " << x << " ";
      }
    }
    cout << "\n";
  }
}
