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