#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, i, j, k;
  string s, t;
  vector<int> ans;
  bool solved = true;
  cin >> n >> s >> t;
  for (i = 0; i < n; i++) {
    bool matched = false;
    for (j = i; j < n; j++) {
      if (s[j] == t[i]) {
        matched = true;
        for (k = j - 1; k >= i; k--) {
          ans.push_back(k);
          swap(s[k], s[k + 1]);
        }
        break;
      }
    }
    if (!matched) {
      solved = false;
      break;
    }
  }
  if (!solved)
    cout << "-1\n";
  else {
    cout << ans.size() << "\n";
    for (auto p : ans) cout << p + 1 << " ";
    cout << "\n";
  }
  return 0;
}
