#include <bits/stdc++.h>
using namespace std;
const long long infl = 1LL << 60;
int mod = 998244353;
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s, s1;
    cin >> s >> s1;
    int l = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] - '0' != s1[i] - '0') {
        l++;
      }
    }
    cout << 3 * l << " ";
    for (int i = 0; i < n; i++) {
      if (s[i] - '0' != s1[i] - '0') {
        cout << i + 1 << " " << 1 << " " << i + 1 << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
