#include <bits/stdc++.h>
using namespace std;
const int L = 2000;
const int AB = 26;
int cnt[AB];
char s1[L + 2], s2[L + 2];
int n;
char tmp[L + 2];
vector<int> ans;
void shift(int);
int main() {
  scanf("%d", &n);
  scanf("%s%s", s1 + 1, s2 + 1);
  for (int i = 1; i <= n; ++i) {
    ++cnt[s1[i] - 'a'];
    --cnt[s2[i] - 'a'];
  }
  for (int i = 0; i < AB; ++i) {
    if (cnt[i] != 0) {
      printf("-1\n");
      exit(EXIT_SUCCESS);
    }
  }
  for (int i = n; i >= 1; --i) {
    if (s1[i] == s2[1]) {
      shift(n - i);
      break;
    }
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= n - i; ++j) {
      if (s1[j] == s2[i + 1]) {
        shift(n - j);
        shift(1);
        shift(n);
        break;
      }
    }
  }
  printf("%d\n", (int)ans.size());
  for (int x : ans) {
    printf("%d ", x);
  }
  printf("\n");
  exit(EXIT_SUCCESS);
}
void shift(int x) {
  if (x == 0) {
    return;
  }
  for (int i = 0; i < x; ++i) {
    tmp[i] = s1[n - i];
  }
  for (int i = n; i > x; --i) {
    s1[i] = s1[i - x];
  }
  for (int i = 1; i <= x; ++i) {
    s1[i] = tmp[i - 1];
  }
  ans.push_back(x);
}
