#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k = 0, w = 1;
  cin >> n;
  char a[100], b[100];
  int s[100005];
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) {
    if (a[i] != b[i]) {
      char q;
      int o = 0;
      for (int j = i + 1; j <= n; j++) {
        if (a[j] == b[i]) {
          o = 1;
          for (int l = j; l > i; l--, w++) {
            a[l] = a[l - 1];
            s[w] = l - 1;
            k++;
          }
          break;
        }
      }
      if (o == 0) {
        cout << "-1";
        return 0;
      }
    }
  }
  cout << k << endl;
  for (int i = 1; i <= k; i++) cout << s[i] << ' ';
  return 0;
}
