#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 9;
char s[MAXN], t[MAXN];
int ans[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s%s", s, t);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      int j = i + 1;
      while (j < n && s[j] != t[i]) j++;
      if (j == n) {
        cnt = -1;
        break;
      }
      while (s[i] != t[i]) swap(s[j], s[j - 1]), ans[cnt++] = j--;
    }
  }
  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++) printf("%d%c", ans[i], " \n"[i == cnt - 1]);
}
