#include <bits/stdc++.h>
using namespace std;
long long n, pos[2];
bool nowsta;
string s, t;
vector<long long> ans;
void shift(long long x) {
  string _s = "";
  for (long long i = n - 1; i >= n - x; --i) _s += s[i];
  for (long long i = 0; i < n - x; ++i) _s += s[i];
  s = _s;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> s >> t;
  pos[1] = n - 1;
  while (pos[0] <= pos[1]) {
    long long position = -1;
    for (long long i = n - 1; i >= pos[0] + n - 1 - pos[1]; --i) {
      if (s[i] == t[pos[nowsta]]) {
        position = i;
        break;
      }
    }
    if (position == -1) return cout << -1, 0;
    shift(n - position);
    shift(n - (n - position + pos[0] + n - 1 - pos[1]));
    shift(n - position + pos[0] + n - 1 - pos[1]);
    ans.push_back(n - position);
    ans.push_back(n - (n - position + pos[0] + n - 1 - pos[1]));
    ans.push_back(n - position + pos[0] + n - 1 - pos[1]);
    pos[nowsta] += (!nowsta ? 1 : -1);
    nowsta ^= 1;
  }
  if (nowsta) {
    ans.push_back(pos[0]);
    ans.push_back(n - 1 - pos[1]);
    ans.push_back(n);
  } else {
    ans.push_back(n - 1 - pos[1]);
    ans.push_back(pos[0]);
  }
  cout << ans.size() << '\n';
  for (long long i = 0; i < ans.size(); ++i) cout << ans[i] << ' ';
  return 0;
}
