#include <bits/stdc++.h>
using namespace std;
int n, Asum[2005], Bsum[2005], ans, an[3 * 2005], tp;
char a[2005], b[2005], tmp[2005];
inline void rev(int len) {
  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) {
    ++Asum[a[i] - 'a'];
    ++Bsum[b[i] - 'a'];
  }
  for (int i = 0; i < 26; ++i)
    if (Asum[i] != Bsum[i]) {
      printf("-1");
      return 0;
    }
  for (int i = 1; i <= n; ++i) {
    int num;
    for (int j = 1; j <= n; ++j)
      if (a[j] == b[i]) {
        num = j;
        break;
      }
    an[++ans] = n - num;
    rev(n - num);
    an[++ans] = 1;
    rev(1);
    an[++ans] = n;
    rev(n);
  }
  printf("%d\n", ans);
  for (int i = 1; i <= ans; ++i) printf("%d ", an[i]);
  return 0;
}
