#include <bits/stdc++.h>
using namespace std;
long long n, i, j, ans, st[6666], f[257];
string s, t;
void make(long long j) {
  st[++ans] = n - j;
  st[++ans] = 1;
  st[++ans] = n;
  string c1 = s, c2 = "";
  c2 = c1.substr(0, j);
  c1.erase(0, j);
  reverse(c1.begin(), c1.end());
  c1 = c1 + c2;
  c2 = c1[n - 1];
  c1.erase(c1.end() - 1);
  c1 = c2 + c1;
  reverse(c1.begin(), c1.end());
  s = c1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  cin >> s >> t;
  for (i = 0; i < n; i++) f[s[i]]++;
  for (i = 0; i < n; i++) {
    f[t[i]]--;
    if (f[t[i]] == -1) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++)
      if (t[i - 1] == s[j - 1]) break;
    make(j);
  }
  cout << ans << endl;
  for (i = 1; i <= ans; i++) cout << st[i] << " ";
  cout << endl;
  return 0;
}
