#include <bits/stdc++.h>
using namespace std;
int n, num[30] = {}, cnt = 0, ans[6500];
char a[2005], b[2005], tmp[2005];
void rev(int len) {
  int tp = 0;
  for (int i = 0; i < len; ++i) tmp[++tp] = a[n - i];
  for (int i = 1; i <= n - len; ++i) tmp[++tp] = a[i];
  for (int i = 1; i <= n; ++i) a[i] = tmp[i];
}
int main() {
  scanf("%d%s%s", &n, a + 1, b + 1);
  for (int i = 1; i <= n; i++) num[a[i] - 'a']++, num[b[i] - 'a']--;
  for (int i = 0; i < 26; i++)
    if (num[i] != 0) {
      printf("-1\n");
      return 0;
    }
  for (int i = 1; i <= n; i++) {
    int j;
    for (j = 1; j <= n; j++)
      if (a[j] == b[i]) break;
    ans[cnt++] = n - j, rev(n - j);
    ans[cnt++] = 1, rev(1);
    ans[cnt++] = n, rev(n);
  }
  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++)
    printf("%d%c", ans[i], i == cnt - 1 ? '\n' : ' ');
}
