#include <bits/stdc++.h>
using namespace std;
string s, t;
int n, cnt_s[30], cnt_t[30];
vector<int> op;
void shift_right(void) {
  op.push_back(1);
  char c = s[n - 1];
  for (int i = n - 1; i > 0; --i) {
    s[i] = s[i - 1];
  }
  s[0] = c;
}
void reverse_suffix(int sz) {
  op.push_back(n);
  op.push_back(n - sz);
  for (int i = n - sz, j = n - 1; i < j; ++i, --j) {
    swap(s[i], s[j]);
  }
}
int main() {
  cin >> n >> s >> t;
  for (char c : s) {
    ++cnt_s[c - 'a'];
  }
  for (char c : t) {
    ++cnt_t[c - 'a'];
  }
  for (int i = 0; i < 26; ++i) {
    if (cnt_s[i] != cnt_t[i]) {
      puts("-1");
      return 0;
    }
  }
  for (int it = 0; it < n; ++it) {
    char c = t[n - 1 - it];
    int at = -1;
    for (int j = n - 1; j >= it; --j) {
      if (s[j] == c) {
        at = j;
        break;
      }
    }
    assert(at != -1);
    reverse_suffix(n - at);
    shift_right();
  }
  assert(s == t);
  int k = op.size();
  assert(k <= 6100);
  printf("%d\n", k);
  for (int it : op) {
    printf("%d ", it);
  }
  puts("");
  return 0;
}
