#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int p = 0;
  vector<int> v;
  int f = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      int k = 0;
      int ind = 0;
      for (int j = i + 1; j < n; j++) {
        if (s[j] == t[i]) {
          k = 1;
          ind = j;
          break;
        }
      }
      if (k == 0) {
        cout << "-1";
        f = 1;
        break;
      }
      for (int j = ind; j > i; j--) {
        char c = s[j];
        s[j] = s[j - 1];
        s[j - 1] = c;
        v.push_back(j);
        p++;
      }
    }
  }
  if (f == 0) {
    cout << p << endl;
    for (int i = 0; i < v.size(); i++) {
      cout << v[i] << " ";
    }
  }
  return 0;
}
