#include <bits/stdc++.h>
using namespace std;
string s, t;
vector<int> ans;
inline void Move(int from, int to) {
  while (from != to) {
    swap(s[from - 1], s[from]);
    from--;
    ans.push_back(from + 1);
  }
}
int main() {
  int n;
  cin >> n;
  cin >> s >> t;
  for (int i = 0; i < n; i++) {
    int Find = -1;
    for (int j = i; j < n; j++)
      if (s[j] == t[i]) {
        Find = j;
        break;
      }
    if (Find == -1) return printf("-1"), 0;
    Move(Find, i);
  }
  cout << ans.size() << endl;
  for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] << ' ';
}
