#include <bits/stdc++.h>
using namespace std;
char s[1000100], t[1000100];
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() {
  cin >> n;
  scanf("%s%s", &s, &t);
  for (int i = 0; i < n; i++) {
    int j;
    int flag = 0;
    for (j = 0; j <= n - i - 1; j++) {
      if (s[j] == t[i]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      puts("-1");
      exit(0);
    }
    shift(n - j - 1);
    shift(1);
    shift(n);
  }
  cout << G.size() << endl;
  for (int i = 0; i < G.size(); i++) {
    cout << G[i] << ' ';
  }
  cout << endl;
  return 0;
}
