#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, swap, r;
  string s, t;
  vector<int> ans;
  cin >> n >> s >> t;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      r = s.find(t[i], i + 1);
      if (r == string::npos) {
        cout << -1 << endl;
        return 0;
      }
      for (int j = r; j != i; j--) {
        swap = s[j - 1];
        s[j - 1] = s[j];
        s[j] = swap;
        ans.push_back(j);
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
  return 0;
}
