#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int i = 0;
  vector<int> ans;
  while (i < n) {
    if (s[i] == t[i])
      i++;
    else {
      int j = i + 1;
      bool flag = true;
      while (j < n) {
        if (s[j] == t[i]) {
          flag = false;
          break;
        }
        j++;
      }
      if (flag) {
        cout << -1 << endl;
        return 0;
      }
      for (int k = j; k > i; k--) {
        char ch = s[k - 1];
        s[k - 1] = s[k];
        s[k] = ch;
        ans.push_back(k);
      }
      i++;
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
