#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    unordered_map<char, int> mp;
    if (s.length() != t.length()) {
      cout << -1 << "\n";
      continue;
    }
    unordered_map<char, int> m;
    for (long long i = 0; i < (n); i++) mp[s[i]] += 1;
    int flag = 0;
    for (long long i = 0; i < (n); i++) {
      mp[t[i]] -= 1;
      if (mp[t[i]] < 0) {
        flag = 1;
        break;
      }
    }
    if (flag) {
      cout << -1 << "\n";
      continue;
    }
    vector<long long> ans;
    for (int i = 0; i < n; i++) {
      if (t[i] == s[i]) continue;
      int pos;
      for (int j = i + 1; j < n; j++) {
        if (t[i] == s[j]) {
          pos = j;
          break;
        }
      }
      pos -= 1;
      for (int k = pos; k >= i; k -= 1) {
        ans.emplace_back(k);
        swap(s[k], s[k + 1]);
      }
    }
    cout << ans.size() << "\n";
    for (auto i : ans) cout << i + 1 << " ";
    cout << "\n";
  }
  return 0;
}
