#include <bits/stdc++.h>
using namespace std;
int arr[55];
int dp[55][55 * 55];
int main() {
  int t, N, c;
  cin >> t;
  while (t--) {
    vector<int> ans;
    int n;
    string a, b;
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        if (i > 0) ans.push_back(i + 1);
        ans.push_back(1);
        if (i > 0) ans.push_back(i + 1);
      }
    }
    cout << ans.size() << " ";
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
}
