#include <bits/stdc++.h>
using namespace std;
int n;
string s1, s2;
int main() {
  int i, j, k;
  cin >> n >> s1 >> s2;
  vector<int> A;
  for (i = 0; i < n; i++) {
    if (s1[i] == s2[i]) continue;
    for (j = i + 1; j < n; j++) {
      if (s1[j] == s2[i]) break;
    }
    if (j == n) {
      cout << -1;
      return 0;
    }
    for (k = j - 1; k >= i; k--) {
      A.push_back(k + 1);
      swap(s1[k], s1[k + 1]);
    }
  }
  cout << A.size() << endl;
  if (A.size()) {
    for (i = 0; i < A.size(); i++) {
      cout << A[i] << " ";
    }
  }
}
