#include <bits/stdc++.h>
using namespace std;
int n, a[26], b[26];
char s[5000], ss[5000];
char s1[5000], s2[5000];
vector<int> ans;
void shift(char *s, int x) {
  int t1 = 0, t2 = 0;
  for (int i = n - x + 1; i <= n; ++i) s2[++t2] = s[i];
  reverse(&s2[1], &s2[t2 + 1]);
  for (int i = 1; i <= n - x; ++i) s1[++t1] = s[i];
  for (int i = 1; i <= x; ++i) s[i] = s2[i];
  for (int i = 1; i <= t1; ++i) s[i + t2] = s1[i];
  ans.push_back(x);
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  scanf("%s", ss + 1);
  for (int i = 1; i <= n; ++i) a[s[i] - 97]++, b[ss[i] - 97]++;
  for (int i = 0; i < 26; ++i)
    if (a[i] != b[i]) {
      puts("-1");
      return 0;
    }
  for (int i = 1; i <= n; ++i) {
    int pos;
    for (int j = 1; j <= n; ++j)
      if (s[j] == ss[i]) {
        pos = j;
        break;
      }
    shift(s, n - pos);
    shift(s, 1);
    shift(s, n);
  }
  printf("%d\n", (int)(ans.size()));
  for (int i = 0; i < ans.size(); ++i) printf("%d ", ans[i]);
  return 0;
}
