#include <bits/stdc++.h>
using namespace std;
string s, t;
long long n;
vector<long long> res;
void doOp(long long x) {
  res.push_back(x);
  string a = "";
  string b = "";
  for (long long i = 0; i < s.length() - x; i++) a += s[i];
  for (long long i = s.length() - x; i < s.length(); i++) b += s[i];
  reverse(b.begin(), b.end());
  s = b + a;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> s >> t;
  long long f1[26], f2[26];
  for (long long i = 0; i < 26; i++) f1[i] = f2[i] = 0;
  for (long long i = 0; i < n; i++) f1[s[i] - 'a']++;
  for (long long i = 0; i < n; i++) f2[t[i] - 'a']++;
  for (long long i = 0; i < 26; i++) {
    if (f1[i] != f2[i]) {
      cout << "-1\n";
      exit(0);
    }
  }
  if (s == t) {
    cout << "0\n";
    exit(0);
  }
  long long l = (s.length() - 1) / 2;
  long long r = l + 1;
  vector<char> order;
  for (long long i = 0; i < n; i++) {
    if (i % 2 == 0) {
      order.push_back(t[l]);
      l--;
    } else {
      order.push_back(t[r]);
      r++;
    }
  }
  for (long long x = 0; x < n; x++) {
    char c = order[x];
    long long p = -1;
    for (long long i = n - 1; i >= 0; i--) {
      if (s[i] == c) {
        p = i;
        break;
      }
    }
    doOp(n - p);
    doOp(n - (n - p) - x);
    doOp(x + 1);
  }
  if (s != t) doOp(n);
  cout << res.size() << '\n';
  for (long long i : res) cout << i << ' ';
  cout << '\n';
}
