#include <bits/stdc++.h>
using namespace std;
int n;
string s, t;
vector<int> Ans;
int main() {
  cin >> n >> s >> t;
  for (int i = 0; i < n; ++i) {
    if (s[i] == t[i]) continue;
    char a = t[i];
    int idx = -1;
    for (int j = i + 1; j < n; ++j)
      if (s[j] == a) {
        idx = j;
        break;
      }
    if (idx == -1) return cout << -1, 0;
    idx--;
    while (idx >= i) {
      swap(s[idx], s[idx + 1]);
      Ans.push_back(idx--);
    }
  }
  cout << Ans.size() << endl;
  for (auto it : Ans) cout << it + 1 << " ";
  return 0;
}
