#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s;
  cin >> t;
  int sc[26] = {0}, tc[26] = {0};
  for (int i = 0; i < n; i++) {
    sc[s[i] - 'a']++;
    tc[t[i] - 'a']++;
  }
  int flag = 1;
  for (int i = 0; i < 26; i++) {
    if (sc[i] == tc[i])
      continue;
    else {
      cout << -1 << endl;
      flag = 0;
      break;
    }
  }
  if (flag == 1) {
    int k = 0, change[100005];
    for (int i = 0; i < n; i++)
      if (s[i] == t[i])
        continue;
      else
        for (int j = i + 1; j < n; j++)
          if (s[j] == t[i]) {
            while (j > i) {
              char temp = s[j];
              s[j] = s[j - 1];
              s[j - 1] = temp;
              change[k++] = j;
              j--;
            }
            break;
          }
    cout << k << endl;
    for (int i = 0; i < k; i++) cout << change[i] << " ";
  }
  return 0;
}
