#include <bits/stdc++.h>
using namespace std;
long long inf = 1e9;
long long power(long long x, long long n, long long mod) {
  long long res = 1;
  x %= mod;
  while (n) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  string s1 = s;
  string t1 = t;
  sort(s1.begin(), s1.end());
  sort(t1.begin(), t1.end());
  bool f = 0;
  for (long long i = 0; i < n; i++)
    if (s1[i] != t1[i]) {
      f = 1;
      break;
    }
  vector<long long> ans;
  if (f) {
    cout << "-1\n";
    return 0;
  } else {
    for (long long i = n - 1; i >= 0; i--) {
      if (s[i] != t[i]) {
        for (long long j = 0; j < i; j++) {
          if (s[j] == t[i]) {
            for (long long k = j; k < i; k++) {
              ans.push_back(k);
              swap(s[k], s[k + 1]);
            }
            break;
          }
        }
      }
    }
  }
  cout << ans.size() << '\n';
  for (long long i = 0; i < ans.size(); i++) {
    cout << ans[i] + 1 << " ";
  }
  cout << '\n';
  return 0;
}
