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