#include <bits/stdc++.h>
char s[7000] = {0};
char t[7000] = {0};
int op[7000] = {0};
int tm[7000] = {0};
int a[7000] = {0};
int n;
void com(int x) {
  int i, j;
  j = 0;
  for (i = n; i >= n - x + 1; i--) {
    j++;
    tm[j] = a[i];
  }
  for (i = 1; i <= n - x; i++) {
    j++;
    tm[j] = a[i];
  }
  for (i = 1; i <= n; i++) {
    a[i] = tm[i];
  }
}
int main() {
  int i, j;
  scanf("%d", &n);
  scanf("%s", s);
  scanf("%s", t);
  int prev[700] = {0};
  for (i = 0; i < n; i++) {
    int seen = 0;
    int ok = 0;
    for (j = 0; j < n; j++) {
      if (s[i] == t[j]) {
        seen++;
        if (seen > prev[s[i]]) {
          a[i + 1] = j + 1;
          prev[s[i]]++;
          ok = 1;
          break;
        }
      }
    }
    if (!ok) {
      printf("-1\n");
      return 0;
    }
  }
  int cnt = 0;
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j++) {
      if (a[j] != i) continue;
      cnt++;
      op[cnt] = n;
      com(n);
      cnt++;
      op[cnt] = j - 1;
      com(j - 1);
      cnt++;
      op[cnt] = 1;
      com(1);
      break;
    }
  }
  cnt++;
  op[cnt] = n;
  com(n);
  printf("%d\n", cnt);
  for (i = 1; i <= cnt; i++) {
    printf("%d ", op[i]);
  }
  printf("\n");
}
