#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int cs[26] = {0};
  int ct[26] = {0};
  for (int i = 0; i < n; i++) {
    cs[s[i] - 'a']++;
    ct[t[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (cs[i] != ct[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<int> ans;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == t[i]) continue;
    if (s[0] != t[i]) {
      int cur = 1, cur1 = -1, cur2 = -1;
      while (cur < i) {
        if (s[cur] == t[i]) {
          cur1 = cur;
          if (s[cur - 1] == t[i - 1]) cur2 = cur - 1;
        }
        cur++;
      }
      if (cur2 != -1) {
        ans.emplace_back(n - cur2 - 2);
        ans.emplace_back(n);
        cur = cur2 + 1;
      } else {
        ans.emplace_back(n - cur1 - 1);
        ans.emplace_back(n);
        cur = cur1;
      }
      for (int j = 0; j <= cur / 2; j++) swap(s[j], s[cur - j]);
    }
    ans.emplace_back(n - i - 1);
    ans.emplace_back(n);
    for (int j = 0; j <= i / 2; j++) swap(s[j], s[i - j]);
  }
  cout << ans.size() << endl;
  for (int x : ans) cout << x << ' ';
  return 0;
}
