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