#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc = 0;
  cin >> tc;
  while (tc--) {
    int n;
    string a, b;
    vector<int> ans;
    cin >> n >> a >> b;
    for (int i = 0; i < n; ++i) {
      if (a.at(i) != b.at(i)) {
        ans.push_back(i + 1);
        ans.push_back(1);
        ans.push_back(i + 1);
      }
    }
    cout << ans.size() << ' ';
    for (int x : ans) cout << x << ' ';
    cout << '\n';
  }
  return 0;
}
