#include <bits/stdc++.h>
int n;
int seq[7000];
int tot, len;
char s[3000], t[3000];
char ts[3000];
int equal = 0;
void shift(int p) {
  for (int i = 1; i <= p; ++i) ts[i] = s[n + 1 - i];
  for (int i = n; i >= p + 1; --i) s[i] = s[i - p];
  for (int i = 1; i <= p; ++i) s[i] = ts[i];
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  s[0] = t[0] = '#';
  len = 0;
  int p = (n + 1) / 2, sup = 2 * p;
  int q = 0;
  while (len < n) {
    q = 0;
    for (int j = len + 1; j <= n; ++j) {
      if (s[j] == t[p]) {
        q = j;
        break;
      }
    }
    if (q == 0) break;
    seq[tot] = n - q + 1;
    ++tot;
    shift(seq[tot - 1]);
    seq[tot] = n - len - seq[tot - 1];
    ++tot;
    shift(seq[tot - 1]);
    seq[tot] = n;
    ++tot;
    shift(seq[tot - 1]);
    if (len & 1)
      p = sup - p;
    else
      p = sup - p + 1;
    ++len;
  }
  equal = 1;
  for (int i = 1; i <= n; ++i)
    if (s[i] != t[i]) equal = 0;
  if (!equal) {
    seq[tot] = n;
    ++tot;
    shift(seq[tot - 1]);
  }
  if (len < n)
    printf("-1");
  else {
    printf("%d\n", tot);
    for (int i = 0; i < tot; ++i) printf("%d ", seq[i]);
  }
  return 0;
}
