#include <bits/stdc++.h>
using namespace std;
int modpow(int x, int n) {
  if (!n) return 1 % 1000000007;
  int u = modpow(x, n / 2);
  u = (u * u) % 1000000007;
  if (n % 2) u = (u * x) % 1000000007;
  return u;
}
int inv(int x) { return modpow(x, 1000000007 - 2); }
void seive(long long n) {
  bool prim[n + 1];
  memset(prim, (true), sizeof prim);
  for (long long i = 2; i * i <= n; i++) {
    if (prim[i]) {
      for (long long j = i * 2; j <= n; j += i) prim[j] = false;
    }
  }
}
int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  vector<int> ans;
  for (int j = 0; j < n; j++) {
    if (s[j] != t[j]) {
      int k = j;
      while (t[j] != s[k]) {
        k++;
        if (k == n) {
          cout << "-1";
          return 0;
        }
      }
      while (k != j) {
        ans.push_back(k);
        swap(s[k], s[k - 1]);
        k--;
      }
    }
  }
  cout << ans.size() << "\n";
  for (long long i = 0, _n = (ans.size()); i < _n; i++) cout << ans[i] << " ";
  return 0;
}
