#include <bits/stdc++.h>
using namespace std;
const int ABC = 26;
int n, cnts[ABC], cntt[ABC];
string s, t;
vector<int> ans;
void update(int sz) {
  ans.push_back(sz);
  string res = "";
  for (int i = 0; i < sz; i++) {
    res += s[n - 1 - i];
  }
  for (int i = 0; i < n - sz; i++) {
    res += s[i];
  }
  s = res;
}
int find(char a) {
  for (int i = 0; i < n; i++)
    if (s[i] == a) return i;
  assert(false);
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s >> t;
  for (auto cur : s) cnts[cur - 'a']++;
  for (auto cur : t) cntt[cur - 'a']++;
  for (int i = 0; i < ABC; i++) {
    if (cnts[i] == cntt[i]) continue;
    cout << -1 << endl;
    return 0;
  }
  for (auto cur : t) {
    update(n - 1 - find(cur));
    update(1);
    update(n - 1);
  }
  cout << ans.size() << endl;
  for (auto cur : ans)
    cout << cur << " "
         << "";
  cout << endl;
  assert(s == t);
  return 0;
}
