#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  string s, t;
  cin >> s;
  cin >> t;
  vector<int> moves;
  int k = 0;
  string s1 = s;
  std::sort(s1.begin(), s1.end());
  string t1 = t;
  std::sort(t1.begin(), t1.end());
  if (s == t) {
    cout << "0";
  } else if (s1 != t1) {
    cout << "-1";
  } else {
    for (int i = 0; i < n; i++) {
      int pos = 0;
      if (s[i] != t[i]) {
        for (int j = i; j < n; j++) {
          if (s[j] == t[i]) {
            pos = j;
            break;
          }
        }
        while (pos != i) {
          int temp = s[pos - 1];
          s[pos - 1] = s[pos];
          s[pos] = temp;
          moves.push_back(pos);
          pos -= 1;
          k++;
        }
      }
    }
    cout << k << endl;
    for (auto i : moves) {
      cout << i << " ";
    }
  }
}
