#include <bits/stdc++.h>
using namespace std;
int MAX(int a, int b) {
  if (a > b) return a;
  return b;
}
int MIN(int a, int b) {
  if (a < b) return a;
  return b;
}
int toar(char a) {
  if (a >= 'A' && a <= 'Z') return a - 'A';
  return a - 'a' + 26;
}
int main() {
  int const sz = 100;
  long long i, n, k, j, m;
  long long a[sz + 1], b[sz + 1];
  string s, t;
  cin >> n >> s >> t;
  vector<int> ans;
  for (i = 0; i < n; i++) {
    if (s[i] == t[i]) continue;
    bool fl = 0;
    for (j = i + 1; j < n; j++)
      if (s[j] == t[i]) {
        fl = 1;
        break;
      }
    if (fl == 0) {
      cout << "-1";
      return 0;
    }
    int k;
    for (k = j; k > i; k--) {
      ans.push_back(k);
      char u = s[k - 1];
      s[k - 1] = s[k];
      s[k] = u;
    }
  }
  cout << ans.size() << "\n";
  for (i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
