#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  int n;
  vector<int> vec;
  scanf("%d", &n);
  getchar();
  getline(cin, s);
  getline(cin, t);
  map<char, int> mp, mp2;
  for (int i = 0; i < n; i++) {
    mp[s[i]]++;
  }
  for (int i = 0; i < n; i++) {
    mp2[t[i]]++;
  }
  for (auto it = mp.begin(), it2 = mp2.begin(); it != mp.end(); it++, it2++) {
    if (it->first == it2->first && it->second == it2->second) {
      continue;
    } else {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      for (int j = i + 1; j < n; j++) {
        if (s[j] == t[i]) {
          for (int k = j - 1; k >= i; k--) {
            swap(s[k], s[k + 1]);
            vec.push_back(k + 1);
          }
          break;
        }
      }
    }
  }
  int len = vec.size();
  printf("%d\n", len);
  for (int i = 0; i < len; i++) {
    printf("%d ", vec[i]);
  }
  return 0;
}
