#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  string s1, s2;
  cin >> s1 >> s2;
  int temp;
  vector<int> index;
  for (int i = 0; i < t; i++) {
    temp = -1;
    if (s1[i] == s2[i]) {
      continue;
    }
    for (int j = i + 1; j < t; j++) {
      if (s1[j] == s2[i]) {
        temp = j;
        break;
      }
    }
    if (temp == -1) {
      printf("%d", temp);
      return 0;
    }
    for (int j = temp - 1; j >= i; j--) {
      swap(s1[j], s1[j + 1]);
      index.push_back(j + 1);
    }
  }
  printf("%d\n", index.size());
  for (int i = 0; i < index.size(); i++) {
    printf("%d ", index[i]);
  }
}
