#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 50;
int n, res[N], m;
string s, t;
bool not_euqal() {
  auto p = s, q = t;
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  return p != q;
}
void op(int x) {
  if (x == 0) return;
  res[++m] = x;
  auto t = s.substr(n - x);
  s = s.substr(0, n - x);
  reverse(t.begin(), t.end());
  s = t + s;
}
void put_front(int i, int j) {
  assert(i <= j);
  op(n);
  op(j);
  op(1);
}
int main() {
  cin >> n;
  cin >> s >> t;
  if (not_euqal()) return puts("-1"), 0;
  for (int i = 0; i < (n); ++i) {
    char c = t[n - 1 - i];
    for (int j = i; j < (n); ++j)
      if (s[j] == c) {
        put_front(i, j);
        break;
      }
  }
  printf("%d\n", m);
  for (int i = 1; i <= (m); ++i) printf("%d%c", res[i], " \n"[i == m]);
  return 0;
}
