#include <bits/stdc++.h>
using namespace std;
int N;
string S, T;
int cnt[26];
vector<int> sol;
string proc(int x) {
  string ret;
  for (int i = N - 1; i >= N - x; i--) {
    ret.push_back(S[i]);
  }
  for (int i = 0; i < N - x; i++) {
    ret.push_back(S[i]);
  }
  return ret;
}
void go(int x) {
  sol.push_back(N);
  S = proc(sol.back());
  sol.push_back(x);
  S = proc(sol.back());
  sol.push_back(1);
  S = proc(sol.back());
}
int main() {
  cin >> N >> S >> T;
  for (int i = 0; i < N; i++) {
    cnt[S[i] - 'a']++;
    cnt[T[i] - 'a']--;
  }
  for (int i = 0; i < 26; i++)
    if (cnt[i] != 0) {
      printf("-1");
      return 0;
    }
  for (int i = N - 1; i >= 0; i--) {
    int p;
    for (int j = N - 1; j >= N - 1 - i; j--) {
      if (S[j] == T[i]) {
        p = j;
        break;
      }
    }
    go(p);
  }
  printf("%d\n", sol.size());
  for (int i = 0; i < sol.size(); i++) {
    printf("%d ", sol[i]);
  }
}
