#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n;
string s, t, k;
void Swap(int p) {
  string nw = "";
  for (int i = n - 1; i >= p; i--) {
    nw += s[i];
  }
  for (int i = 0; i < p; i++) {
    nw += s[i];
  }
  s = nw;
}
vector<int> ans;
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> s >> t;
  int p = (n - 1) / 2, q = (n - 1) / 2;
  for (int i = 1; i <= n; i++) {
    k += t[p];
    if (i % 2)
      swap(p, q), p++;
    else
      swap(p, q), p--;
  }
  for (int i = 0; i < n; i++) {
    p = -1;
    for (int j = i; j < n; j++) {
      if (k[i] == s[j]) p = j;
    }
    if (p == -1) {
      cout << -1;
      return 0;
    }
    Swap(p);
    Swap(i + n - p);
    Swap(0);
    ans.push_back(p);
    ans.push_back(i + n - p);
    ans.push_back(0);
  }
  if (n % 2) Swap(0), ans.push_back(0);
  cout << ans.size() << '\n';
  for (int i : ans) {
    cout << n - i << ' ';
  }
}
