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