#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int freq[26], cn[26];
  memset(freq, 0, sizeof freq);
  memset(cn, 0, sizeof cn);
  for (int i = 0; i < s.size(); i++) freq[s[i] - 'a']++, cn[t[i] - 'a']++;
  bool OK = true;
  for (int i = 0; i < 26; i++)
    if (freq[i] != cn[i]) {
      OK = false;
      break;
    }
  if (!OK)
    cout << -1 << endl;
  else {
    vector<int> ans;
    for (int i = 0; i < t.size(); i++) {
      int pos;
      for (int j = i; j < s.size(); j++)
        if (s[j] == t[i]) {
          pos = j;
          break;
        }
      for (int j = pos; j > i; j--) {
        swap(s[j], s[j - 1]);
        ans.push_back(j - 1);
      }
    }
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << " ";
    cout << endl;
  }
  return 0;
}
