#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
vector<int> op(vector<int> v, int x) {
  int n = v.size();
  vector<int> v2;
  for (int i = n - x; i < n; i++) {
    v2.push_back(v[i]);
  }
  reverse(v2.begin(), v2.end());
  for (int i = 0; i < n - x; i++) v2.push_back(v[i]);
  return v2;
}
void disp(vector<int> v) {
  for (int i : v) cout << i << ' ';
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<int> ctss(26), ctst(26), v(n), goal(n), ans;
  for (int i = 0; i < n; i++) {
    v[i] = s[i] - 'a';
    goal[i] = t[i] - 'a';
    ctss[s[i] - 'a']++;
    ctst[t[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (ctss[i] != ctst[i]) {
      cout << -1;
      return 0;
    }
  }
  bool flip = 0;
  for (int len = 0; len < n; len++, flip = !flip) {
    int p = -1;
    if (flip) {
      for (int i = 0; i < n; i++) {
        if (v[i] == goal[n - 1 - len]) {
          p = i;
          break;
        }
      }
      v = op(v, n - 1 - p);
      v = op(v, 1);
      ans.push_back(n - 1 - p);
      ans.push_back(1);
    } else {
      for (int i = n - 1; i >= 0; i--) {
        if (v[i] == goal[n - 1 - len]) {
          p = i;
          break;
        }
      }
      v = op(v, n - p);
      v = op(v, n);
      v = op(v, n - 1 - p);
      ans.push_back(n - p);
      ans.push_back(n);
      ans.push_back(n - 1 - p);
    }
  }
  if (flip) ans.push_back(n);
  cout << ans.size() << '\n';
  for (int i : ans) cout << i << ' ';
  return 0;
}
