#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
const int N = 6e3 + 100;
bool debug = false;
char s[N], t[N], need, ss[N];
int tot, ans[N];
int n, id;
void gao(int x) {
  if (!x) return;
  ans[++tot] = x;
  for (int i = 1; i <= n - x; ++i) ss[x + i] = s[i];
  for (int i = 1; i <= x; ++i) ss[i] = s[n + 1 - i];
  for (int i = 1; i <= n; ++i) s[i] = ss[i];
}
int main() {
  bool flag = true;
  scanf("%d", &n);
  scanf("%s%s", s + 1, t + 1);
  for (int i = 1, be = (n + 1) >> 1; i <= n && flag; ++i) {
    if (i & 1)
      need = t[be - (i >> 1)];
    else
      need = t[be + (i >> 1)];
    id = n + 1;
    for (int j = 1; j <= n - i + 1 && id > n; ++j)
      if (s[j] == need) id = j;
    if (id > n)
      flag = false;
    else {
      gao(n - id);
      gao(1);
      gao(n - i);
    }
  }
  if (!(n & 1)) gao(n);
  if (flag) {
    printf("%d\n", tot);
    for (int i = 1; i <= tot; ++i) printf("%d%c", ans[i], " \n"[i == tot]);
  } else
    puts("-1");
  return 0;
}
