#include <bits/stdc++.h>
using namespace std;
int n, cnt[30];
char sir1[2010], sir2[2010];
vector<int> rez;
void solve(int poz) {
  rez.push_back(poz);
  reverse(sir1 + 1, sir1 + (n - poz) + 1);
  reverse(sir1 + 1, sir1 + n + 1);
}
int main() {
  scanf("%d\n", &n);
  scanf("%s\n", sir1 + 1);
  scanf("%s", sir2 + 1);
  for (int i = 1; i <= n; i++) cnt[sir1[i] - 'a']++;
  for (int i = 1; i <= n; i++) cnt[sir2[i] - 'a']--;
  for (int i = 0; i < 26; i++)
    if (cnt[i] != 0) {
      printf("-1");
      return 0;
    }
  for (int i = 1; i <= n; i++) {
    int poz = 1;
    for (; sir1[poz] != sir2[i]; poz++)
      ;
    solve(n - poz);
    solve(1);
    solve(n);
  }
  printf("%d\n", rez.size());
  for (int i = 0; i < rez.size(); i++) printf("%d ", rez[i]);
  return 0;
}
