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