#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10;
const int INF = 0x3f3f3f3f;
int casn, n, m, k;
char a[maxn], b[maxn], t[maxn];
int ans[maxn], cnt;
void swift(int len) {
  if (len == 0) return;
  reverse(a, a + n);
  reverse(a + len, a + n);
  ans[++cnt] = len;
}
int main() {
  cin >> n >> a >> b;
  for (int i = 0; i <= n - 1; i++) {
    int j = i;
    while (j < n && a[j] != b[n - i - 1]) j++;
    if (j == n) {
      cout << -1 << endl;
      return 0;
    }
    swift(n);
    swift(j);
    swift(1);
  }
  cout << cnt << endl;
  for (int i = 1; i <= cnt; i++) {
    cout << ans[i] << ' ';
  }
  return 0;
}
