#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int ans = 0;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      char cur = t[i];
      int ind = -1;
      for (int j = i + 1; j < n; j++)
        if (s[j] == cur) ind = j;
      if (ind == -1) {
        cout << -1;
        return 0;
      }
      for (int j = ind - 1; j >= i; j--) {
        swap(s[ind], s[j]);
        ind = j;
        v.push_back(j + 1);
        ans++;
      }
    }
  }
  cout << ans << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
}
