#include <bits/stdc++.h>
using namespace std;
char s[2003];
char t[2003];
vector<int> ans;
int main() {
  int n;
  scanf("%d%s%s", &n, s, t);
  bool failed = false;
  for (int i = 0; i < n; i++) {
    int tgt = -1;
    for (int j = n - 1 - i; j >= 0; j--) {
      if (s[j] == t[i]) {
        tgt = j;
        break;
      }
    }
    if (tgt == -1) {
      failed = true;
      break;
    }
    ans.push_back(n - tgt - 1);
    ans.push_back(1);
    ans.push_back(n);
    reverse(s, s + tgt);
    for (int j = tgt; j < n - 1; j++) s[j] = s[j + 1];
    s[n - 1] = t[i];
  }
  if (failed)
    printf("-1\n");
  else {
    printf("%d\n", ans.size());
    for (auto it : ans) printf("%d ", it);
    printf("\n");
  }
  return 0;
}
