#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
bool ok(string a, string b) {
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  return a == b;
}
string shift(string s, int x, vector<int>* ops) {
  ops->push_back(x);
  const int n = s.size();
  if (x == n) {
    reverse(s.begin(), s.end());
    return s;
  }
  string end = s.substr(n - x, x);
  reverse(end.begin(), end.end());
  return end + s.substr(0, n - x);
}
int main() {
  ios::sync_with_stdio(false);
  cout.precision(12);
  int n;
  cin >> n;
  string s;
  string t;
  cin >> s >> t;
  if (!ok(s, t)) {
    cout << -1 << endl;
    return 0;
  }
  bool reversed = false;
  int i = t.find(s[0]);
  int j = t.find(s[0]);
  vector<int> ops;
  for (int k = 1; k < n; ++k) {
    int target;
    if (reversed) {
      j = (j + 1) % n;
      target = s.find(t[j], k);
    } else {
      i = (i + n - 1) % n;
      target = s.find(t[i], k);
    }
    s = shift(s, n - target - 1, &ops);
    s = shift(s, target - k + 1, &ops);
    s = shift(s, k, &ops);
    reversed = !reversed;
  }
  if (reversed) s = shift(s, n, &ops);
  if (i != 0) {
    s = shift(s, n, &ops);
    s = shift(s, n - i, &ops);
    s = shift(s, j + 1, &ops);
  }
  cout << ops.size() << endl;
  for (const int o : ops) {
    cout << o << " ";
  }
  cout << endl;
  return 0;
}
