#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 x, y, a, b;
  cin >> x >> y;
  a = x;
  b = y;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a == b) {
    vector<pair<int, int> > v;
    for (int i = 0; i < n; i++) {
      if (x[i] != y[i]) {
        for (int j = i; j < n; j++) {
          if (x[j] == y[i]) {
            if (j == i + 1) {
              swap(x[i], x[j]);
              v.push_back(make_pair(i + 1, j + 1));
            } else {
              for (int k = j; k > i; k--) {
                swap(x[k], x[k - 1]);
                v.push_back(make_pair(k, k + 1));
              }
            }
            break;
          }
        }
      }
    }
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++) {
      cout << v[i].first << " ";
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
