#include <bits/stdc++.h>
using namespace std;
const long long N = 1001 * 1001;
long long cnt[26];
void shift(string& s, long long x) {
  long long n = s.size();
  string t = "";
  for (long long i = n - x; i < n; i++) t += s[i];
  reverse(t.begin(), t.end());
  for (long long i = 0; i < n - x; i++) t += s[i];
  s = t;
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long n;
  string s, t;
  cin >> n >> s >> t;
  for (long long i = 0; i < n; i++) cnt[s[i] - 'a']++;
  for (long long i = 0; i < n; i++) cnt[t[i] - 'a']--;
  for (long long i = 0; i < 26; i++)
    if (cnt[i]) return cout << -1 << endl, 0;
  vector<long long> ans;
  for (long long i = 0; i < n; i++) {
    long long id = 0;
    for (long long j = 0; j < n - i; j++)
      if (s[j] == t[i]) id = j;
    ans.push_back(n - id - 1);
    ans.push_back(1);
    ans.push_back(n);
    shift(s, n - id - 1);
    shift(s, 1);
    shift(s, n);
  }
  cout << ans.size() << '\n';
  for (auto u : ans) cout << u << ' ';
  cout << endl;
}
