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