#include <bits/stdc++.h>
using namespace std;
int n;
string s, t;
vector<int> sol;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> s >> t;
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j < n and s[j] != t[i]) j++;
    if (j == n) {
      cout << "-1" << endl;
      return 0;
    }
    for (; j > i; j--) {
      swap(s[j], s[j - 1]);
      sol.push_back(j);
    }
  }
  if (sol.size() > 1e4) {
    cout << "-1" << endl;
    return 0;
  }
  cout << int(sol.size()) << endl;
  for (int i = 0; i < int(sol.size()); i++) {
    if (i > 0) cout << " ";
    cout << sol[i];
  }
  cout << endl;
}
