#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> move;
  char s[51], t[51];
  cin >> n;
  cin.ignore();
  cin.get(s, 51, '\n');
  cin.ignore();
  cin.get(t, 51, '\n');
  int i = 0;
  while (i < n) {
    if (s[i] != t[i]) {
      int j = i + 1;
      while (j < n && s[j] != t[i]) j++;
      if (j == n) {
        cout << -1;
        return 0;
      }
      for (int t = j - 1; t >= i; t--) {
        move.push_back(t + 1);
        char c = s[t];
        s[t] = s[t + 1];
        s[t + 1] = c;
      }
    }
    i++;
  }
  cout << move.size() << endl;
  for (i = 0; i < move.size(); i++) cout << move[i] << " ";
  return 0;
}
