#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int c1[26], c2[26];
  memset(c1, 0, sizeof(c1));
  memset(c2, 0, sizeof(c2));
  for (i = 0; i < n; i++) {
    c1[s[i] - 'a']++;
  }
  for (i = 0; i < n; i++) {
    c2[t[i] - 'a']++;
  }
  for (i = 0; i < 26; i++) {
    if (c1[i] != c2[i]) break;
  }
  if (i != 26) {
    cout << -1;
    return 0;
  }
  int c = 0, j;
  vector<long long> v;
  for (i = 0; i < n; i++) {
    if (s[i] == t[i]) continue;
    for (j = i + 1; j < n; j++) {
      if (s[j] == t[i]) break;
    }
    j--;
    for (; j >= i; j--) {
      swap(s[j], s[j + 1]);
      v.push_back(j + 1);
    }
  }
  cout << v.size() << endl;
  for (i = 0; i < v.size(); i++) cout << v[i] << " ";
}
