#include <bits/stdc++.h>
using namespace std;
const int maxn = 21000;
char S[maxn], T[maxn], tmp[maxn], tmp2[maxn];
int n, x, y, L, R, flag = 1;
vector<int> ans;
map<char, int> d;
void rotate(int v) {
  if (v <= n - R - 1) L += v, R += v;
  ans.push_back(v);
  memcpy(tmp, S + n - v, v);
  memcpy(tmp2, S, n - v);
  reverse(tmp, tmp + v);
  memcpy(S, tmp, v);
  memcpy(S + v, tmp2, n - v);
}
int yield() {
  if (flag) {
    if (y == n - 1) return -1;
    return T[y + 1];
  } else {
    if (x == 0) return -1;
    return T[x - 1];
  }
}
void next() {
  if (flag)
    y += 1;
  else
    x -= 1;
  flag ^= 1;
}
void thro() {
  int front = n - R - 1, len = R - L + 1;
  rotate(n - L);
  L = front, R = L + len - 1;
}
void print() {
  puts(S);
  printf("L:%d R:%d (x:%d y:%d)\n", L, R, x, y);
}
int main() {
  scanf("%d", &n);
  scanf("%s %s", S, T);
  for (int i = 0; i < n; ++i) {
    d[S[i]]++;
    d[T[i]]--;
  }
  bool ok = true;
  for (auto i : d)
    if (i.second != 0) ok = false;
  if (!ok) {
    puts("-1");
    return 0;
  }
  x = (n - 1) / 2, y = (n - 1) / 2;
  L = strchr(S, T[x]) - S, R = L;
  rotate(n - R - 1);
  thro();
  while (y - x + 1 < n) {
    int c = yield();
    if (c == -1) {
      rotate(n - R - 1);
      thro();
      next();
      continue;
    }
    int idx = strchr(S + R + 1, c) - S;
    rotate(n - idx - 1);
    rotate(n - R - 1);
    thro();
    next();
    R += 1;
  }
  if (flag) thro();
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
