#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
char s[maxn], t[maxn];
int c[10010], vis[maxn], cnts[30], cntt[30];
int main() {
  int k, n;
  scanf("%d", &n);
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  memset(cnts, 0, sizeof(cnts));
  memset(cntt, 0, sizeof(cntt));
  for (int i = 1; i <= n; ++i) {
    cnts[s[i] - 'a']++;
    cntt[t[i] - 'a']++;
  }
  int flag = 1;
  for (int i = 0; i < 26; ++i) {
    if (cnts[i] != cntt[i]) {
      flag = 0;
      break;
    }
  }
  if (flag == 0) {
    puts("-1");
  } else {
    memset(c, 0, sizeof(c));
    int num = 0;
    for (int i = 1; i <= n; ++i) {
      if (s[i] != t[i]) {
        for (int j = i; j <= n; ++j) {
          if (s[j] == t[i]) {
            for (int k = j - 1; k >= i; --k) {
              c[num++] = k;
              char te;
              te = s[k];
              s[k] = s[k + 1];
              s[k + 1] = te;
            }
            break;
          }
        }
      }
    }
    printf("%d\n", num);
    for (int i = 0; i < num; ++i) {
      if (i != 0) printf(" ");
      printf("%d", c[i]);
    }
    puts("");
  }
}
