#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  vector<long long int> v;
  long long int pos;
  for (int i = 0; i < n; i++) {
    if (s1[i] == s2[i]) continue;
    pos = -1;
    for (int j = i + 1; j < n; j++) {
      if (s1[j] == s2[i]) {
        pos = j;
      }
    }
    if (pos < 0) {
      cout << "-1\n";
      return 0;
    }
    for (int j = pos - 1; j >= i; j--) {
      swap(s1[j], s1[j + 1]);
      v.push_back(j);
    }
  }
  cout << v.size() << "\n";
  for (auto it = v.begin(); it != v.end(); it++) {
    cout << *it + 1 << " ";
  }
}
