#include <bits/stdc++.h>
using namespace std;
const int N = 33358;
const double pi = acos(-1.0);
const int fx[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
const int ff[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
                      {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
const long long MOD = 1000000007LL;
const int MAX = 1000000000;
void gcd(long long a, long long b, long long &d, long long &x, long long &y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    gcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
long long inv(long long a, long long n) {
  long long d, x, y;
  gcd(a, n, d, x, y);
  return (x + n) % n;
}
int n;
char s1[N], s2[N], s3[N];
void zexal(int x) {
  for (int i = 1; i <= x; ++i) s3[i] = s1[n - i + 1];
  for (int i = x + 1; i <= n; ++i) s3[i] = s1[i - x];
  for (int i = 1; i <= n; ++i) s1[i] = s3[i];
}
queue<int> ans;
int cnt1[27], cnt2[27];
int main() {
  int cases;
  cases = 1;
  for (int iii = 1; iii <= cases; ++iii) {
    scanf("%d", &n);
    scanf("%s", s1 + 1);
    scanf("%s", s2 + 1);
    for (int i = 1; i <= n; ++i) {
      cnt1[s1[i] - 'a']++;
      cnt2[s2[i] - 'a']++;
    }
    bool ok = true;
    for (int i = 0; i < 26; ++i) {
      if (cnt1[i] != cnt2[i]) {
        ok = false;
        break;
      }
    }
    if (!ok) {
      printf("-1\n");
      continue;
    }
    for (int i = n; i >= 1; --i)
      if (s1[i] == s2[1]) {
        if (i < n) {
          ans.push(n - i);
          zexal(n - i);
        }
        break;
      }
    for (int i = 2; i <= n; ++i) {
      int temp = n - i + 1;
      while (s1[temp] != s2[i]) --temp;
      ans.push(n - temp);
      zexal(n - temp);
      ans.push(1);
      zexal(1);
      ans.push(n);
      zexal(n);
    }
    printf("%d\n", ans.size());
    while (!ans.empty()) {
      printf("%d", ans.front());
      ans.pop();
      if (ans.empty())
        printf("\n");
      else
        printf(" ");
    }
  }
}
