#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n;
int main() {
  std ::ios ::sync_with_stdio(false);
  string s, t;
  cin >> n >> s >> t;
  map<char, int> mp, mp2;
  for (auto i : s) mp[i]++;
  for (auto i : t) mp2[i]++;
  if (mp != mp2) {
    cout << -1, exit(0);
  }
  vector<int> yo;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      int pos = i;
      for (int j = i + 1; j < n; j++) {
        if (s[j] == t[i]) {
          pos = j;
          break;
        }
      }
      while (pos != i) {
        swap(s[pos], s[pos - 1]);
        yo.push_back(pos);
        pos--;
      }
    }
  }
  cout << yo.size() << '\n';
  for (auto i : yo) cout << i << ' ';
  return 0;
}
