#include <bits/stdc++.h>
using namespace std;
int n;
string s, t;
vector<int> ans;
bool same() {
  string s_1 = s;
  string t_1 = t;
  sort(s_1.begin(), s_1.end());
  sort(t_1.begin(), t_1.end());
  if (s_1 == t_1) {
    return true;
  } else {
    return false;
  }
}
int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin >> n;
  cin >> s >> t;
  if (!same()) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    int idx = 0;
    for (int j = 0; j < n; ++j) {
      if (s[j] == t[i]) {
        idx = j;
        break;
      }
    }
    if (idx != n - 1) {
      ans.push_back(n - idx - 1);
      string back = s.substr(idx + 1);
      reverse(back.begin(), back.end());
      s = back + s.substr(0, idx + 1);
    }
    ans.push_back(1);
    s = s[n - 1] + s.substr(0, n - 1);
    ans.push_back(n);
    reverse(s.begin(), s.end());
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
    if (i) {
      cout << " ";
    }
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
