#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXLEN = 50;
const int MAXRET = 10000;
int n;
char s[MAXLEN + 1];
char t[MAXLEN + 1];
int ret[MAXRET], nret;
void run() {
  scanf("%d", &n);
  scanf("%s%s", s, t);
  nret = 0;
  for (int i = (0); i < (n); ++i) {
    int j = -1;
    for (int jj = (i); jj < (n); ++jj)
      if (s[jj] == t[i]) {
        j = jj;
        break;
      }
    if (j == -1) {
      printf("-1\n");
      return;
    }
    for (int k = j - 1; k >= i; --k) ret[nret++] = k, swap(s[k], s[k + 1]);
    assert(s[i] == t[i]);
  }
  printf("%d\n", nret);
  for (int i = (0); i < (nret); ++i) {
    if (i != 0) printf(" ");
    printf("%d", ret[i] + 1);
  }
  puts("");
}
int main() {
  run();
  return 0;
}
