#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    string a, b;
    cin >> n;
    cin >> a;
    cin >> b;
    int ans = 0;
    vector<int> inds;
    for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
         i += 1 - 2 * ((0) > (n))) {
      if (a[i] != b[i]) {
        ans += 3;
        inds.push_back(i + 1);
        inds.push_back(1);
        inds.push_back(i + 1);
      }
    }
    cout << ans << " ";
    for (__typeof(ans) i = (0) - ((0) > (ans)); i != (ans) - ((0) > (ans));
         i += 1 - 2 * ((0) > (ans))) {
      cout << inds[i] << " ";
    }
    cout << endl;
  }
}
