#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int dx[] = {1, 0, 0, -1};
int dy[] = {0, 1, -1, 0};
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    vector<int> ans;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        ans.push_back(i + 1);
        ans.push_back(1);
        ans.push_back(i + 1);
      }
    }
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++) cout << ' ' << ans[i];
    cout << '\n';
  }
}
