#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10;
char s[N], t[N];
int n;
vector<int> G;
void shift(int x) {
  if (x == 0) return;
  reverse(s, s + n);
  reverse(s + x, s + n);
  G.push_back(x);
}
int main() {
  scanf("%d%s%s", &n, s, t);
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j < n && s[j] != t[n - i - 1]) j++;
    if (j == n) {
      puts("-1");
      exit(0);
    }
    shift(n);
    shift(j);
    shift(1);
  }
  printf("%d\n", G.size());
  for (int i = 0; i < (int)G.size(); ++i) printf("%d ", G[i]);
}
