#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main() {
  int n;
  string s, s2, t, t2;
  cin >> n >> s >> t;
  s2 = s, t2 = t;
  sort(s2.begin(), s2.end()), sort(t2.begin(), t2.end());
  if (s2 != t2) cout << -1 << endl, exit(0);
  vector<int> ans;
  for (int i = 0; i < n - 1; i++)
    if (s[i] != t[i]) {
      for (int j = n; j > i; j--)
        if (s[j] == t[i]) {
          swap(s[j], s[j - 1]);
          ans.push_back(j);
        }
    }
  cout << ans.size() << endl;
  int fst = 1;
  for (auto it : ans) {
    fst ? fst = 0 : putchar(' ');
    cout << it;
  }
  cout << endl;
  return 0;
}
