#include <bits/stdc++.h>
using namespace std;
char getc() {
  char c = getchar();
  while ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9'))
    c = getchar();
  return c;
}
int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); }
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x * f;
}
int n, cnt[2010];
char a[2010], b[2010], c[2010];
signed main() {
  n = read();
  cin >> (a + 1) >> (b + 1);
  for (int i = 1; i <= n; i++) cnt[a[i]]++;
  for (int i = 1; i <= n; i++) cnt[b[i]]--;
  for (int i = 1; i <= 200; i++)
    if (cnt[i]) {
      cout << -1;
      return 0;
    }
  cout << n * 3 << endl;
  for (int i = 1; i <= n; i++) {
    int p = 0;
    for (int j = 1; j <= n; j++)
      if (a[j] == b[i]) {
        p = j;
        break;
      }
    cout << n - p << ' ' << 1 << ' ' << n << ' ';
    reverse(a + p + 1, a + n + 1);
    for (int j = p; j <= n; j++) c[j - p + 1] = a[j];
    for (int j = 1; j < p; j++) c[n - p + 1 + j] = a[j];
    for (int j = 1; j <= n; j++) a[j] = c[j];
    reverse(a + 1, a + n + 1);
  }
  return 0;
}
