#include <bits/stdc++.h>
using namespace std;
int n;
string s, t;
vector<int> ans;
bool chk() {
  int f1[666], f2[666];
  for (int i = 0; i < 665; i++) f1[i] = f2[i];
  for (int i = 0; i < n; i++) f1[s[i] - 'a']++, f2[t[i] - 'a']++;
  for (int i = 0; i < 664; i++)
    if (f1[i] != f2[i]) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s >> t;
  if (chk()) {
    cout << "-1";
    return 0;
  }
  for (int j = n - 1; j >= 0; j--) {
    for (int i = 0; i < j; i++) {
      if (s[i] != t[j]) continue;
      for (int k = i; k < j; k++) ans.push_back(k);
      string tmp = "";
      for (int k = 0; k <= j; k++)
        if (k != i) tmp = tmp + s[k];
      for (int k = j; k < n; k++) tmp = tmp + t[k];
      s = tmp;
      break;
    }
  }
  cout << ans.size() << "\n";
  for (auto yy : ans) cout << yy + 1 << " ";
  return 0;
}
