#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2200;
const int MAXK = 6600;
char s[MAXN], t[MAXN];
char tmp[MAXN];
int n, k, c[MAXK];
void shift(int x) {
  memcpy(tmp, s, sizeof s);
  for (int i = 1; i <= x; i++) s[i] = tmp[n - i + 1];
  for (int i = x + 1; i <= n; i++) s[i] = tmp[i - x];
  c[++k] = x;
}
int main() {
  scanf("%d%s%s", &n, s + 1, t + 1);
  int f = 0;
  for (int i = 1, l = 1, r = 0; i <= n; i++) {
    int p = 1;
    while (p <= n && (p >= l && p <= r || s[p] != t[i])) p++;
    if (p == n + 1) {
      puts("-1");
      return 0;
    }
    if (f == 0) {
      if (p > r) {
        shift(n - p);
        shift(n);
        shift(n - p + r);
        l = n - p + l, r = l + i - 1, f = 0;
      } else {
        shift(n - r);
        shift(n);
        shift(n - r + p);
        l = n - r + p, r = l + i - 1, f = 1;
      }
    } else {
      if (p > r) {
        shift(n - p);
        shift(p - r);
        shift(r - l + 1);
        l = 1, r = i, f = 0;
      } else {
        shift(n - p);
        shift(n);
        shift(n - l + 1);
        l = n - r + 1, r = l + i - 1, f = 0;
      }
    }
  }
  if (f == 1) shift(n);
  printf("%d\n", k);
  for (int i = 1; i <= k; i++) printf("%d ", c[i]);
  putchar('\n');
  return 0;
}
