#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  deque<char> s, t;
  char temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    s.push_back(temp);
  }
  for (int i = 0; i < n; i++) {
    cin >> temp;
    t.push_back(temp);
  }
  int fromfront = 0;
  while (s.front() == t.front() && s.size() > 0) {
    s.pop_front();
    t.pop_front();
    fromfront++;
  }
  while (s.back() == t.back() && s.size() > 0) {
    s.pop_back();
    t.pop_back();
  }
  vector<int> myvect;
  int counter = 0;
  bool contradiction = false;
  if (s.size() > 0) {
    while (s != t && s.size() > 0 && !contradiction) {
      int pos = 0;
      while (s[pos] != t.front() && pos < s.size()) {
        pos++;
      }
      if (pos == min(t.size(), s.size())) {
        contradiction = true;
      } else {
        for (int j = pos - 1; j >= 0; j--) {
          swap(s[j + 1], s[j]);
          myvect.push_back(j + fromfront);
          counter++;
        }
        s.pop_front();
        t.pop_front();
        fromfront++;
      }
    }
  } else {
    cout << "0";
    return 0;
  }
  if (contradiction) {
    cout << "-1";
    return 0;
  } else {
    cout << counter << endl;
    for (int i = 0; i < myvect.size(); i++) {
      cout << myvect[i] + 1 << " ";
    }
  }
}
