#include <bits/stdc++.h>
using namespace std;
char s[2020], t[2020], tmp[2020];
int sum = 0;
int n;
int ans[4 * 2020];
void op(int x) {
  int cnt = 0;
  for (int i = n; i > n - x; i--) tmp[++cnt] = s[i];
  for (int i = 1; i <= n - x; i++) tmp[++cnt] = s[i];
  for (int i = 1; i <= n; i++) s[i] = tmp[i];
  ans[++sum] = x;
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  int now = n;
  for (int i = 1; i <= n; i++) {
    int j = i;
    while (j <= n && s[j] != t[n - i + 1]) j++;
    if (j == n + 1) {
      printf("-1\n");
      return 0;
    }
    op(n);
    op(j - 1);
    op(1);
  }
  printf("%d\n", sum);
  for (int i = 1; i <= sum; i++) printf("%d ", ans[i]);
  printf("\n");
}
