#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    map<char, long long int> a, b;
    long long int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (long long int i = 0; i < n; i++) a[s[i]]++, b[t[i]]++;
    vector<long long int> ans;
    if (a != b)
      cout << -1;
    else {
      if (s == t)
        cout << 0;
      else {
        std::vector<int> move;
        for (int i = n - 1; i >= 0; --i) {
          if (s[i] != t[i]) {
            int j = i - 1;
            for (j = i - 1; j >= 0; --j) {
              if (s[j] == t[i]) break;
            }
            while (j < i) {
              move.push_back(j + 1);
              swap(s[j], s[j + 1]);
              ++j;
            }
          }
        }
        cout << move.size() << '\n';
        for (int x : move) cout << x << " ";
      }
    }
  }
  return 0;
}
