#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string a, b;
  cin >> n;
  cin >> a;
  cin >> b;
  if (a == b) {
    printf("0\n");
    return 0;
  }
  int arr[256] = {0};
  for (int i = 0; i < n; i++) {
    arr[a[i]]++;
    arr[b[i]]--;
  }
  for (int i = 0; i < 256; i++)
    if (arr[i] != 0) return !printf("-1\n");
  vector<short> aa;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i]) continue;
    int j, pos;
    for (j = i + 1; j < n; j++) {
      if (a[j] == b[i]) {
        pos = j;
        break;
      }
    }
    for (int j = pos - 1; j >= i; --j) {
      swap(a[j], a[j + 1]);
      aa.push_back(j + 1);
    }
  }
  cout << aa.size() << endl;
  for (int i = 0; i < aa.size(); i++) {
    cout << aa[i] << " ";
  }
  return 0;
}
