#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
string s, t, Tmp;
int n, cnt[33];
vector<int> ans;
void apply(int x) {
  ans.push_back(x);
  Tmp.clear();
  for (int i = n - x; i < n; ++i) Tmp += s[i];
  for (int i = n - 1; i - x >= 0; --i) s[i] = s[i - x];
  reverse(Tmp.begin(), Tmp.end());
  for (int i = 0; i < x; ++i) s[i] = Tmp[i];
}
void go(int i, int j) {
  apply(n - j - 1);
  apply(j - i + 1);
  apply(i);
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> s >> t;
  for (int i = 0; i < n; ++i) cnt[s[i] - 'a']++;
  for (int i = 0; i < n; ++i) cnt[t[i] - 'a']--;
  for (int i = 0; i < 26; ++i)
    if (cnt[i]) return cout << -1 << '\n', 0;
  for (int i = 0; i < n; ++i)
    if (s[i] == t[(n - 1) / 2]) {
      apply(n - i - 1);
      apply(1);
      break;
    }
  int L = (n - 1) / 2, R = L;
  for (int rp = 0; rp < n - 1; ++rp) {
    if (rp % 2 == 0) {
      for (int i = rp + 1; i < n; ++i)
        if (s[i] == t[R + 1]) {
          go(rp + 1, i);
          break;
        }
      R++;
    } else {
      for (int i = rp + 1; i < n; ++i)
        if (s[i] == t[L - 1]) {
          go(rp + 1, i);
          break;
        }
      L--;
    }
  }
  if (s != t) apply(n);
  cout << ((int)(ans).size()) << '\n';
  for (auto x : ans) cout << x << ' ';
  cout << '\n';
  return 0;
}
