#include <bits/stdc++.h>
using namespace std;
const int maxn = 2100;
char s[maxn], t[maxn];
int n;
vector<int> ans;
void shift(int x) {
  reverse(s, s + x + 1);
  reverse(s + 1, s + x + 1);
  reverse(s + x + 1, s + n);
}
int main() {
  scanf("%d%s%s", &n, s, t);
  for (int i = n - 1; i >= 0; i--) {
    int k = n - i - 1;
    while (s[k] != t[i] && k < n) {
      k++;
    }
    if (k == n) {
      printf("-1\n");
      return 0;
    }
    if (k != 0) {
      ans.push_back(n);
      ans.push_back(k);
      ans.push_back(1);
      shift(k);
    }
  }
  printf("%d\n", ans.size());
  for (int i : ans) {
    printf("%d ", i);
  }
  printf("\n");
  return 0;
}
