#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<long long> v;
  map<char, long long> m, mp;
  if (s == t) {
    cout << 0 << endl;
    return 0;
  }
  for (long long i = 0; i < n; i++) {
    m[s[i]]++;
    mp[t[i]]++;
  }
  for (long long i = 0; i < n; i++) {
    if (m[s[i]] != mp[s[i]]) {
      cout << -1 << endl;
      return 0;
    }
  }
  long long pos;
  for (long long i = 0; i < n; i++) {
    if (s[i] == t[i]) continue;
    pos = -1;
    for (long long j = i + 1; j < n; j++) {
      if (t[i] == s[j]) {
        pos = j;
        break;
      }
    }
    for (long long j = pos - 1; j >= i; j--) {
      swap(s[j], s[j + 1]);
      v.push_back(j + 1);
    }
  }
  cout << v.size() << endl;
  for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
}
