#include <bits/stdc++.h>
using namespace std;
int c[10001] = {0};
int main() {
  int n, we = 0, flag = 0;
  cin >> n;
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      for (int j = n - 1; j > i; j--) {
        if (a[j] == b[i]) {
          for (int k = j; k > i; k--) {
            c[we++] = k;
            int t = a[k];
            a[k] = a[k - 1];
            a[k - 1] = t;
            break;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << we << endl;
  if (we != 0) cout << c[0];
  for (int i = 1; i < we; i++) cout << " " << c[i];
  cout << endl;
}
