#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
char ch[N], s[N], tmp[N];
int n, c1[30], c2[30], ans[N * 3], top;
int main() {
  scanf("%d", &n);
  scanf("%s%s", ch + 1, s + 1);
  for (int i = 1; i <= n; i++) c1[ch[i] - 'a']++, c2[s[i] - 'a']++;
  for (int i = 0; i < 26; i++)
    if (c1[i] != c2[i]) {
      puts("-1");
      return 0;
    }
  for (int i = 1; i <= n; i++) {
    int j = n - i + 1;
    while (ch[j] != s[i]) j--;
    if (j == n) continue;
    ans[++top] = n - j, ans[++top] = 1, ans[++top] = n;
    int m = 0;
    for (int k = j - 1; k; k--) tmp[++m] = ch[k];
    for (int k = j + 1; k <= n; k++) tmp[++m] = ch[k];
    tmp[++m] = ch[j];
    memcpy(ch, tmp, sizeof(ch));
  }
  printf("%d\n", top);
  for (int i = 1; i <= top; i++) printf("%d ", ans[i]);
  return 0;
}
