#include <bits/stdc++.h>
using namespace std;
int n;
string s, t;
int x[6000 + 10], ii = 0;
void pop() {
  x[ii++] = 1;
  char c = s.back();
  s.erase(s.end() - 1);
  s.insert(s.begin(), c);
}
void revSuffix(int l) {
  if (l <= 1) return;
  x[ii++] = n;
  x[ii++] = n - l;
  reverse(s.begin() + n - l, s.end());
}
void work() {
  for (int i = n - 1; i >= 0; i--) {
    int j = n - 1;
    while (j >= 0 && s[j] != t[i]) j--;
    if (j < 0) {
      ii = -1;
      return;
    }
    revSuffix(n - j);
    pop();
  }
  if (s != t) ii = -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> s >> t;
  work();
  printf("%d\n", ii);
  for (int i = 0; i < ii; i++) printf("%d ", x[i]);
  printf("\n");
}
