#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
char s[N], t[N];
int n;
long long ans[N * 10], k = 0;
void re(int x) {
  if (x == 0) return;
  char a1[N], b1[N];
  for (int i = n - 1, j = 1; j <= x; i--, j++) a1[j] = s[i];
  for (int i = 0; i < n - x; i++) b1[i] = s[i];
  int ss = 0;
  for (int i = 1; i <= x; i++) s[ss++] = a1[i];
  for (int i = 0; i < n - x; i++) s[ss++] = b1[i];
  ans[++k] = x;
}
int main() {
  scanf("%d%s%s", &n, s, t);
  for (int i = 0; i < n; i++) {
    int j = 0;
    while (j < n - i && s[j] != t[i]) j++;
    if (j == n - i) {
      printf("-1\n");
      return 0;
    }
    re(n - j - 1);
    re(1);
    re(n);
  }
  printf("%d\n", k);
  for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
