#include <bits/stdc++.h>
using namespace std;
string a, b;
int ans[6000];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, i, j, now = 0, ok = 0;
    memset(ans, 0, sizeof(ans));
    cin >> n;
    cin >> a;
    cin >> b;
    for (i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        ans[now++] = i + 1, ans[now++] = 1, ans[now++] = i + 1;
      }
    }
    cout << now << ' ';
    for (i = 0; i < now; i++) cout << ans[i] << ' ';
    (cout << endl);
  }
  return 0;
}
