#include <bits/stdc++.h>
using namespace std;
long long int arr[1000000], brr[1000000], crr[1000000];
string str, str1;
int flag = 0;
int main() {
  long long int t, i, j, k, n, x, y, z, a, b, c, l, r, mid, l1, r1, m, maxx,
      amaxx;
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> str;
    cin >> str1;
    i = 0;
    k = 0;
    while (i < n) {
      if (str[i] != str1[i]) {
        arr[k++] = i + 1;
        if (i > 0) {
          arr[k++] = 1;
          arr[k++] = i + 1;
        }
      }
      i++;
    }
    cout << k << " ";
    for (i = 0; i < k; i++) {
      cout << arr[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
