#include <bits/stdc++.h>
using namespace std;
long long n;
long long a, b, k, m;
long long mini = 0;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long q, H, e, D, C, w, x, y, i;
  cin >> n;
  string s, t;
  cin >> s >> t;
  std::vector<long long> v1;
  for (long long i = 0; i < n; i++) {
    if (s[i] == t[i]) continue;
    long long pos = -1;
    for (long long j = i + 1; j < n; j++) {
      if (t[i] == s[j]) {
        pos = j;
        break;
      }
    }
    if (pos == -1) {
      return cout << -1, 0;
    }
    for (long long j = pos - 1; j >= i; j--) {
      swap(s[j + 1], s[j]);
      v1.push_back(j);
    }
  }
  cout << v1.size() << '\n';
  for (auto x : v1) {
    cout << x + 1 << " ";
  }
  return 0;
}
