#include <bits/stdc++.h>
using namespace std;
string a, b, c;
vector<int> ans;
int cnt1[30], cnt2[30];
int main() {
  int n;
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cnt1[a[i] - 'a']++;
    cnt2[b[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (cnt1[i] != cnt2[i]) {
      puts("-1");
      return 0;
    }
  }
  int l = (n - 1) / 2, r = l;
  int x = a.find(b[l]);
  x++;
  string tmp = a.substr(0, x);
  a = a.substr(0 + x, n - x);
  reverse(tmp.begin(), tmp.end());
  a = tmp + a;
  ans.push_back(n - x);
  ans.push_back(n);
  int _ = 1, cnt = 1;
  c = a.substr(0, 1);
  while (cnt != n) {
    reverse(c.begin(), c.end());
    int nx;
    if (_ & 1)
      nx = ++r;
    else
      nx = --l;
    _ ^= 1;
    int pos = a.find(b[nx], cnt);
    a = c + a.substr(pos, n - pos) + a.substr(cnt, pos - cnt);
    c += b[nx];
    ans.push_back(n - pos);
    ans.push_back(pos - cnt);
    ans.push_back(n);
    cnt++;
  }
  if (a != b) ans.push_back(n);
  cout << ans.size() << endl;
  for (int i : ans) {
    cout << i << " ";
  }
  return 0;
}
