#include <bits/stdc++.h>
using namespace std;
int n, is, it;
vector<int> res;
string s, t;
int getis() {
  for (int i = it; i < t.size(); ++i) {
    if (s[i] == t[it]) return i;
  }
  return -1;
}
int main() {
  cin >> n >> s >> t;
  while (s != t) {
    is = getis();
    if (is == -1) {
      cout << -1;
      return 0;
    }
    while (is >= 0 && is > it) {
      res.push_back(is - 1);
      swap(s[is - 1], s[is]);
      is--;
    }
    it++;
  }
  if (res.size() > 10000) {
    cout << -1;
    return 0;
  }
  cout << res.size() << endl;
  for (int i : res) cout << i + 1 << " ";
  return 0;
}
