#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5;
int n, l, r, cnt[26], f[26], m, y;
vector<int> re;
string s, t;
int tab(int u) {
  string v, q;
  v = q = "";
  re.push_back(u);
  for (int i = s.size() - 1; i >= (int)s.size() - u; i--) {
    v.push_back(s[i]);
  }
  for (int i = 0; i < s.size() - u; ++i) {
    q.push_back(s[i]);
  }
  s = v + q;
}
int find(char c) {
  int o = y;
  for (int i = s.size() - y - 1; i >= 0; i--) {
    if (s[i] != c)
      o++;
    else
      return o;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s >> t;
  for (auto u : s) {
    cnt[u - 'a']++;
  }
  for (auto u : t) {
    f[u - 'a']++;
  }
  for (int i = 0; i < 26; ++i) {
    if (cnt[i] != f[i]) {
      cout << -1;
      return 0;
    }
  }
  int x = find(t[0]);
  y = 1;
  if (x != 0) tab(x);
  while (y != t.size()) {
    x = find(t[y]);
    y++;
    tab(x);
    tab(1);
    tab(s.size());
  }
  cout << re.size() << endl;
  for (auto u : re) {
    cout << u << ' ';
  }
  return 0;
}
