#include <bits/stdc++.h>
using namespace std;
const double g = 10.0, eps = 1e-12;
const int N = 100000 + 10, maxn = 100000 + 10, inf = 0x3f3f3f3f,
          INF = 0x3f3f3f3f3f3f3f3f;
char s[N], p[N];
int n;
vector<int> ans;
void shift(int x) {
  ans.push_back(x);
  reverse(s + 1, s + 1 + n);
  reverse(s + 1 + x, s + 1 + n);
}
int main() {
  scanf("%d%s%s", &n, s + 1, p + 1);
  for (int i = 1; i <= n; i++) {
    bool ok = 1;
    for (int j = 1; j <= n + 1 - i; j++) {
      if (s[j] == p[i]) {
        ok = 0;
        shift(n - j);
        shift(1);
        shift(n - 1);
        break;
      }
    }
    if (ok) return 0 * puts("-1");
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  puts("");
  return 0;
}
