#include <bits/stdc++.h>
using namespace std;
char s[2005];
char t[2005];
vector<int> otp;
int n;
void work(int x) {
  reverse(s + 1, s + n + 1);
  reverse(s + n + 1 - x, s + n + 1);
  otp.push_back(n - x);
}
int cnt[26];
int main() {
  cin >> n;
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  for (int i = 1; i <= n; i++) {
    cnt[s[i] - 'a']++, cnt[t[i] - 'a']--;
  }
  for (int i = 0; i < 26; i++)
    if (cnt[i]) {
      printf("-1\n");
      return 0;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (s[j] == t[i]) {
        work(j);
        work(n - 1);
        work(0);
        break;
      }
  cout << otp.size() << endl;
  for (auto v : otp) cout << v << ' ';
  cout << endl;
  return 0;
}
