#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return b < a ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
const int maxn = 2010;
int n;
char a[maxn + 5], b[maxn + 5];
vector<int> ans;
inline void work(int first) {
  ans.push_back(first);
  rotate(a, a + n - first, a + n);
  reverse(a, a + first);
}
int main() {
  scanf("%d", &n);
  scanf("%s%s", a, b);
  for (int i = (0), i_end_ = (n); i < i_end_; ++i) {
    int p = -1;
    for (int j = (i), j_end_ = (n); j < j_end_; ++j)
      if (a[j] == b[i]) {
        p = j;
        break;
      }
    if (!~p) {
      printf("-1\n");
      return 0;
    }
    work(n);
    work(p);
    work(1);
  }
  work(n);
  for (int i = (0), i_end_ = (n); i < i_end_; ++i) assert(a[i] == b[i]);
  printf("%d\n", (int((ans).size())));
  for (auto u : ans) printf("%d ", u);
  return 0;
}
