#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  long long j = 0;
  vector<long long> v;
  long long k = 0;
  for (long long i = 0; i < n; i++) {
    if (t[i] == s[j]) {
      j++;
    } else {
      long long u = j;
      while (u < n && s[u] != t[i]) {
        u++;
      }
      if (u == n) {
        k = 1;
        break;
      }
      while (u != j) {
        char c = s[u];
        s[u] = s[u - 1];
        s[u - 1] = c;
        v.push_back(u);
        u--;
      }
      j++;
    }
  }
  if (k || v.size() > 10000) {
    cout << -1 << endl;
  } else {
    cout << v.size() << endl;
    for (int i = int(0); i <= int(v.size() - 1); i++) {
      cout << v[i] << " ";
    }
  }
}
