#include <bits/stdc++.h>
using namespace std;
int n;
bool cmp(pair<int, int>& a, pair<int, int>& b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first < b.first;
}
int solve(string& s, string& t, vector<int>& ans) {
  vector<int> cnt(256, 0);
  for (auto& i : s) cnt[i]++;
  for (auto& i : t) {
    cnt[i]--;
    if (cnt[i] < 0) return -1;
  }
  for (int i = 0; i < n; i++) {
    if (t[i] == s[i]) continue;
    int j = s.find(t[i], i);
    while (j > i) {
      ans.push_back(--j);
      swap(s[j], s[j + 1]);
    }
  }
  return ans.size();
}
int main() {
  string s, t;
  cin >> n >> s >> t;
  vector<int> ans;
  if (solve(s, t, ans) == -1)
    cout << -1 << endl;
  else {
    cout << ans.size() << endl;
    if (!ans.empty()) {
      for (int i = 0; i < ans.size() - 1; i++) cout << ans[i] + 1 << ' ';
      cout << ans.back() + 1 << endl;
    }
  }
}
