#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  string s, t;
  cin >> n >> s >> t;
  vector<int> k;
  for (int i = 0, c; i < n; ++i) {
    if (s[i] == t[i]) continue;
    c = -1;
    for (int j = i + 1; j < n; ++j) {
      if (s[j] == t[i]) {
        c = j;
        break;
      }
    }
    if (c == -1) {
      cout << c;
      return 0;
    }
    for (int j = c - 1; j >= i; --j) {
      swap(s[j], s[j + 1]);
      k.push_back(j);
    }
  }
  cout << k.size() << endl;
  for (int i : k) cout << i + 1 << ' ';
  return 0;
}
