#include <bits/stdc++.h>
using namespace std;
string a, b;
vector<int> s;
int main() {
  int n;
  cin >> n;
  cin >> a >> b;
  string c = a, d = b;
  sort(c.begin(), c.end());
  sort(d.begin(), d.end());
  int pos = 0;
  if (c != d)
    cout << -1;
  else {
    for (int i = 0; i < n; i++) {
      int pos = -1;
      if (a[i] == b[i]) continue;
      for (int j = i + 1; j < n; j++) {
        if (a[j] == b[i]) {
          pos = j;
          break;
        }
      }
      for (int k = pos - 1; k >= i; k--) {
        swap(a[k], a[k + 1]);
        s.push_back(k);
      }
    }
    cout << s.size() << endl;
    for (int i : s) cout << i + 1 << " ";
  }
  return 0;
}
