#include <bits/stdc++.h>
using namespace std;
long long i = 0;
long long n;
string s, t;
vector<long long> history;
void conv(long long x) {
  if (x == 0) return;
  string s2;
  history.push_back(x);
  for (long long j = 0; j < x; j++) {
    s2 += s.back();
    s.pop_back();
  }
  s = s2 + s;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  cin >> s >> t;
  vector<char> order;
  long long l = 0, r = n - 1;
  bool turn = true;
  while (l <= r) {
    if (turn)
      order.push_back(t[l++]);
    else
      order.push_back(t[r--]);
    turn = !turn;
  }
  reverse((order).begin(), (order).end());
  for (; i < n; i++) {
    conv(i);
    long long cnt = 0;
    for (long long j = n - 1; j >= 0; j--) {
      cnt++;
      if (s[j] == order[i]) break;
    }
    conv(cnt);
    conv(n - i - cnt);
  }
  if (s != t) conv(n);
  if (s != t) {
    cout << -1;
    return 0;
  }
  cout << (long long)(history).size() << "\n";
  for (long long x : history) cout << x << " ";
}
