#include <bits/stdc++.h>
using namespace std;
bool anagram(int n, string s, string t) {
  int arr[130], ptr[130];
  for (int i = 97; i < 130; i++) {
    arr[i] = 0;
    ptr[i] = 0;
  }
  int i = 0;
  while (i < n) {
    ++arr[s[i]];
    ++ptr[t[i]];
    i++;
  }
  for (i = 97; i < 130; i++) {
    if (arr[i] != ptr[i]) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<int> res;
  if (anagram(n, s, t)) {
    int i = n - 1;
    while (i >= 0) {
      if (s[i] != t[i]) {
        int j = i;
        while (s[j] != t[i]) j--;
        while (j < i) {
          res.push_back(j);
          char temp = s[j];
          s[j] = s[j + 1];
          s[j + 1] = temp;
          j++;
        }
      }
      i--;
    }
    int len = res.size();
    cout << len << '\n';
    for (int i = 0; i < len; i++) cout << res[i] + 1 << ' ';
  } else
    cout << "-1";
}
