#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t, temps, tempt;
  int n, i, k;
  cin >> n;
  cin >> s;
  cin >> t;
  for (i = 0; i < n; i++) {
    temps += s[i];
    tempt += t[i];
  }
  sort(tempt.begin(), tempt.end());
  sort(temps.begin(), temps.end());
  for (i = 0; i < n; i++) {
    if (temps[i] != tempt[i]) {
      cout << -1;
      return 0;
    }
  }
  vector<int> mv;
  for (i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      for (k = i; k < n; k++) {
        if (s[k] == t[i]) break;
      }
      while (k > i) {
        mv.push_back(k);
        swap(s[k], s[k - 1]);
        k--;
      }
    }
  }
  if (mv.size() > 10000)
    cout << -1;
  else {
    cout << mv.size() << endl;
    for (k = 0; k < mv.size(); k++) cout << mv[k] << " ";
  }
}
