#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long int> vec;
  long long int i, j, k, n, count = 0, c = 0, d = 0;
  cin >> n;
  string a, t;
  cin >> a >> t;
  if (a == t) {
    cout << 0 << endl;
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (t[i] != a[i]) {
      c = 0;
      for (j = i + 1; j < n; j++) {
        if (t[i] == a[j]) {
          for (k = j; k > i; k--) {
            swap(a[k], a[k - 1]);
            count++;
            vec.push_back(k - 1);
          }
          break;
        }
      }
    }
  }
  if (a != t)
    cout << -1 << endl;
  else {
    cout << count << endl;
    for (i = 0; i < count; i++) {
      cout << ++vec[i];
      if (i != count - 1)
        cout << " ";
      else
        cout << endl;
    }
  }
  return 0;
}
