#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 10;
char str[MAXN], ans[MAXN], str2[MAXN];
int len, num[30], sum, p, p2;
vector<int> a;
void shift(int x) {
  if (x == 0) {
    return;
  }
  int p = -1;
  for (int i = len - 1; i > len - 1 - x; --i) {
    str2[++p] = str[i];
  }
  for (int i = 0; i <= len - 1 - x; ++i) {
    str2[++p] = str[i];
  }
  for (int i = 0; i < len; ++i) {
    str[i] = str2[i];
  }
}
int main() {
  scanf("%d", &len);
  scanf("%s %s", str, ans);
  a.clear();
  memset(num, 0, sizeof(num));
  sum = 0;
  for (int i = 0; i < len; ++i) {
    ++num[ans[i] - 'a'];
    --num[str[i] - 'a'];
  }
  for (int i = 0; i < 26; ++i) {
    if (num[i] != 0) {
      printf("-1");
      return 0;
    }
  }
  printf("%d\n", 3 * len);
  for (int i = 1; i <= len; ++i) {
    int p;
    for (int j = 0; j < len; ++j) {
      if (str[j] == ans[i - 1]) {
        p = j;
        break;
      }
    }
    shift(len - 1 - p);
    shift(1);
    shift(len - 1);
    printf("%d\n%d\n%d\n", len - 1 - p, 1, len - 1);
  }
  return 0;
}
