#include <bits/stdc++.h>
using namespace std;
int n;
string a, b, temp;
vector<int> v;
int main() {
  a += "0";
  b += "0";
  cin >> n;
  cin >> temp;
  a += temp;
  cin >> temp;
  b += temp;
  for (int i = 1; i <= n; i++) {
    if (a[i] == b[i]) continue;
    int getpos = -1;
    for (int j = i + 1; j <= n; j++) {
      if (a[j] == b[i]) {
        getpos = j;
        break;
      }
    }
    if (getpos == -1) {
      cout << "-1" << endl;
      return 0;
    } else {
      for (int k = getpos - 1; k >= i; k--) {
        v.push_back(k);
        swap(a[k], a[k + 1]);
      }
    }
  }
  if (v.size() > 10000) {
    cout << "-1" << endl;
  } else {
    cout << v.size() << endl;
    for (auto i : v) cout << i << " ";
  }
  cout << endl;
  return 0;
}
