#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 7;
const int M = 2333;
int n;
char s[N], t[N];
vector<int> ans;
void shift(int x) {
  if (x == 0) return;
  reverse(s, s + n);
  reverse(s + x, s + n);
  ans.push_back(x);
}
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  scanf("%s", t);
  for (int i = 0; i < n; i++) {
    int now = 0;
    while (s[now] != t[i]) now++;
    if (now >= n - i) {
      puts("-1");
      return 0;
    }
    shift(n - 1 - now);
    shift(1);
    shift(n - 1);
  }
  printf("%d\n", ans.size());
  for (int i : ans) printf("%d ", i);
  puts("");
  return 0;
}
