#include <bits/stdc++.h>
using namespace std;
const int maxn = 2020;
const int mod = 1e9 + 7;
const int INF = 999999999;
double eps = 1e-8;
char s[maxn], t[maxn];
int ans[maxn * 3], k = 0;
void res(int x, int n) {
  reverse(s, s + n);
  if (x < n) reverse(s + x, s + n);
  ans[k++] = x;
}
void solve() {
  int n;
  cin >> n >> s >> t;
  for (int i = n - 1, j; i >= 0; i--) {
    for (j = n - i - 1; j < n && t[i] != s[j]; j++)
      ;
    if (j == n) {
      cout << -1 << endl;
      return;
    }
    res(n, n);
    res(j, n);
    res(1, n);
  }
  cout << k << endl;
  for (int i = 0; i < k; i++) {
    if (i != 0) printf(" ");
    printf("%d", ans[i]);
  }
  cout << endl;
}
int main() {
  solve();
  int mark_EOF;
  if (scanf("%d", &mark_EOF) == EOF) return 0;
  return 0;
}
