#include <bits/stdc++.h>
using namespace std;
int n, m, a[1000];
string s, t;
queue<int> q;
int main() {
  cin >> n;
  cin >> s >> t;
  int luu;
  for (int i = 0; i < n; i++) {
    if (s[i] == t[i]) continue;
    luu = -1;
    for (int j = i + 1; j < n; j++)
      if (s[j] == t[i]) {
        luu = j;
        break;
      }
    if (luu == -1) break;
    for (int j = luu; j > i; j--) {
      swap(s[j], s[j - 1]);
      q.push(j - 1);
    }
  }
  if (luu == -1)
    cout << -1;
  else {
    cout << q.size() << '\n';
    while (!q.empty()) {
      cout << q.front() + 1 << " ";
      q.pop();
    }
  }
  return 0;
}
