#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const int MAXN = 200001;
string s, t;
int c[26];
int n;
void shift(int x) {
  cout << x << " ";
  string lst = s.substr(n - x);
  s = string(lst.rbegin(), lst.rend()) + s.substr(0, n - x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(20);
  cout.tie(nullptr);
  cin.tie(nullptr);
  cin >> n;
  cin >> s >> t;
  for (char ch : s) {
    ++c[ch - 'a'];
  }
  for (char ch : t) {
    if (--c[ch - 'a'] < 0) {
      cout << -1 << "\n";
      return 0;
    }
  }
  cout << 3 * n << "\n";
  for (int i = n - 1; i >= 0; --i) {
    int p = n - 1;
    while (s[p] != t[i]) {
      --p;
    }
    shift(n);
    shift(p);
    shift(1);
  }
  assert(s == t);
}
