#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[55], t[55];
  int re1[55];
  int re2[55];
  int n;
  cin >> n;
  cin.get();
  memset(re1, 0, sizeof(re1));
  memset(re2, 0, sizeof(re2));
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    re1[s[i] - 'a']++;
  }
  cin.get();
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    re2[t[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (re1[i] != re2[i]) {
      cout << "-1" << endl;
      return 0;
    }
  }
  int ans = 0;
  int res[10005];
  char ts;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != t[i]) {
      for (int j = i + 1; j < n; j++) {
        if (s[j] == t[i]) {
          for (int k = j - 1; k >= i; k--) {
            ts = s[k];
            s[k] = s[k + 1];
            s[k + 1] = ts;
            res[ans++] = k;
          }
          break;
        }
      }
    }
  }
  cout << ans << endl;
  for (int i = 0; i < ans; i++) {
    if (i == 0)
      cout << res[i] + 1;
    else
      cout << " " << res[i] + 1;
  }
  return 0;
}
