#include <bits/stdc++.h>
using namespace std;
int value[1000];
vector<int> ans;
int main() {
  int n;
  cin >> n;
  char s[51], t[51], s_1[51], t_1[51];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    s_1[i] = s[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    t_1[i] = t[i];
  }
  sort(s_1, s_1 + n);
  sort(t_1, t_1 + n);
  for (int i = 0; i < n; i++) {
    if (s_1[i] != t_1[i]) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (t[i] != s[i]) {
      for (int j = i + 1; j < n; j++) {
        if (t[i] == s[j]) {
          for (int k = j - 1; k >= i; k--) {
            swap(s[k], s[k + 1]);
            ans.push_back(k);
          }
          break;
        }
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << " ";
}
