#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<char> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  vector<char> t(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    if (s[i] == t[i]) {
      continue;
    } else {
      char target = t[i];
      for (int j = n - 2; j >= i; j--) {
        if (s[j + 1] == target) {
          swap(s[j], s[j + 1]);
          ans.push_back(j + 1);
        }
      }
      if (s[i] != t[i]) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
