#include <bits/stdc++.h>
using namespace std;
int n, nxt[40404], x, st, ds[27], dr[27];
char s[2020], r[2020];
int main() {
  scanf("%d", &n);
  scanf("%s%s", s, r);
  for (int i = 0; i < n; i++) {
    ds[s[i] - 'a']++;
    dr[r[i] - 'a']++;
  }
  for (int i = 0; i <= 25; i++)
    if (ds[i] != dr[i]) {
      printf("-1\n");
      return 0;
    }
  printf("%d\n", n * 3);
  for (int i = 0; i < n; i++) {
    for (int j = st; j < st + n; j++)
      if (s[j] == r[i]) {
        x = j;
        break;
      }
    s[st + n] = s[x];
    s[x] = s[st++];
    for (int j = st; j < (st + x) / 2; j++) swap(s[j], s[x - j + st - 1]);
    printf("%d 1 %d ", st + n - x - 2, n);
  }
  return 0;
}
