#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<int> f1(26);
  vector<int> f2(26);
  for (int i = 0; i < n; i++) {
    f1[s[i] - 97]++;
    f2[t[i] - 97]++;
  }
  int f = 0;
  for (int i = 0; i < 26; i++) {
    if (f1[i] != f2[i]) {
      f = 1;
      break;
    }
  }
  if (f == 1)
    cout << "-1" << endl;
  else {
    int cou = 0;
    vector<int> v;
    for (int i = 0; i < n; i++) {
      if (s[i] == t[i]) continue;
      int c = 0;
      for (int j = i + 1; j < n; j++) {
        if (t[i] == s[j]) {
          c++;
          break;
        }
        c++;
      }
      char x = s[i];
      s[i] = s[i + c];
      s[i + c] = x;
      for (int k = 1; k < c; k++) {
        v.push_back(i + k);
      }
      v.push_back(i + c);
      for (int k = 1; k < c; k++) {
        v.push_back(i + c - k);
      }
      cou = cou + 2 * c - 1;
    }
    cout << cou << endl;
    for (int i = 0; i < cou; i++) cout << v[i] << " ";
    cout << endl;
  }
  return 0;
}
