#include <bits/stdc++.h>
using namespace std;
const long long MAX = 100005;
const long long MOD = 1000000007;
const double PI = 2 * acos(0.0);
const double EPS = 0.00000000001;
int main() {
  int n, c = 0;
  cin >> n;
  string s, t;
  cin >> s >> t;
  if (s == t) {
    cout << 0 << endl;
    return 0;
  }
  map<char, int> ha, fa;
  for (int i = 0; i < s.size(); i++) {
    ha[s[i]]++;
  }
  for (int i = 0; i < t.size(); i++) {
    fa[t[i]]++;
  }
  for (char i = 'a'; i <= 'z'; i++) {
    if (ha[i] != fa[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<int> a;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      for (int j = i + 1; j < s.size(); j++) {
        if (t[i] == s[j]) {
          for (int k = j; k > i; k--) {
            swap(s[k], s[k - 1]);
            a.push_back(k - 1);
          }
          break;
        }
      }
    }
  }
  if (a.size() > 10000) {
    cout << -1 << endl;
    return 0;
  }
  cout << a.size() << endl;
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] + 1 << " ";
  }
  return 0;
}
