#include <bits/stdc++.h>
using namespace std;
const long long N = 1 << 20, M = 1 << 17, mod = 1e9 + 7, inf = 3e18;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  long long L = n / 2, R = L, id = n, flag = n % 2;
  vector<long long> ans;
  for (long long i = 0; i < n; i++) {
    string tmp;
    while (s.size() != id) tmp.push_back(s.back()), s.pop_back();
    s = tmp + s;
    ans.push_back(n - id);
    tmp.clear();
    for (long long j = 1; j <= i; j++) tmp.push_back(s.back()), s.pop_back();
    s = tmp + s;
    ans.push_back(i);
    tmp.clear();
    char ch = t[flag ? L : R];
    while (s.size() > i && s.back() != ch)
      tmp.push_back(s.back()), s.pop_back();
    if (s.size() == i || s.back() != ch) cout << -1, exit(0);
    tmp.push_back(s.back()), s.pop_back();
    s = tmp + s;
    ans.push_back(tmp.size());
    id = tmp.size() + i;
    flag ? ++R : --L;
    flag ^= 1;
  }
  cout << ans.size() << "\n";
  for (long long x : ans) cout << x << ' ';
}
