#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
const int mxn = 1e6 + 10;
const int inf = 1e9;
string s, t;
int n, cnt_ops;
vector<int> ans;
bool ok() {
  vector<int> fs(26, 0);
  vector<int> ft(26, 0);
  for (char c : s) fs[c - 'a']++;
  for (char c : t) ft[c - 'a']++;
  return fs == ft;
}
void ops(int len) {
  cnt_ops++;
  ans.push_back(len);
  if (!len) return;
  string tmp = s.substr(n - len, len);
  tmp = string(tmp.rbegin(), tmp.rend());
  s = tmp + s.substr(0, n - len);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> s >> t;
  if (!ok()) {
    cout << -1 << '\n';
    return 0;
  }
  int md = (n - 1) / 2, add = 0, len = 0;
  while (s != t) {
    if (md + add > n - 1 or md + add < 0) {
      ops(n);
      break;
    }
    char k = t[md + add];
    int ind = -1;
    for (int i = 0; i < n; i++)
      if (s[i] == k) {
        ind = i;
        break;
      }
    ops(len);
    ops(n - ind - len);
    ops(ind);
    add = add == 0 ? 1 : add > 0 ? -add : -(add - 1);
    len++;
  }
  cout << cnt_ops << '\n';
  for (int x : ans) cout << x << " ";
  cout << '\n';
  return 0;
}
