#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n, cntS[28], cntT[28];
char s[N], t[N];
vector<int> ans;
int main() {
  scanf("%d", &n);
  memset(cntS, 0, sizeof(cntS));
  memset(cntT, 0, sizeof(cntT));
  scanf("%s%s", s, t);
  for (int i = 0; i < n; i++) {
    cntS[s[i] - 'a']++;
  }
  for (int i = 0; i < n; i++) {
    cntT[t[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (cntS[i] != cntT[i]) {
      printf("-1\n");
      return 0;
    }
  }
  string nowS = "";
  for (int i = 0; i < n; i++) {
    nowS = nowS + s[i];
  }
  int len = 0;
  ans.clear();
  while (len != n) {
    int id;
    for (int i = n - 1; i >= 0; i--) {
      if (nowS[i] == t[n - 1 - len]) {
        id = i;
        break;
      }
    }
    ans.push_back(n);
    ans.push_back(id);
    ans.push_back(1);
    string backS = "";
    backS = backS + nowS[id];
    for (int i = 0; i < id; i++) {
      backS = backS + nowS[i];
    }
    for (int i = n - 1; i > id; i--) {
      backS = backS + nowS[i];
    }
    nowS = backS;
    len++;
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    if (i != 0) printf(" ");
    printf("%d", ans[i]);
  }
  return 0;
}
