#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> ans;
string s, t;
void shift(int x) {
  ans.push_back(n - x);
  if (x == 0) {
    reverse(s.begin(), s.end());
    return;
  }
  string temp = s.substr(x, n - x);
  for (; n - x > 0; ++x) s.pop_back();
  reverse(temp.begin(), temp.end());
  s = temp + s;
}
int main() {
  cin >> n >> s >> t;
  string S = s, T = t;
  sort(S.begin(), S.end());
  sort(T.begin(), T.end());
  if (S != T) {
    cout << -1;
    return 0;
  }
  bool flag = false;
  for (int i = 0, x; i < n; ++i) {
    if (flag) {
      for (x = i; x < n; ++x) {
        if (s[x] == t[i]) break;
      }
      shift(x);
      shift(i + n - x);
      shift(0);
      flag = false;
    } else {
      if (s[i] == t[i]) continue;
      if (s[n - 1] == t[i]) {
        shift(0);
        shift(n - i);
        continue;
      }
      for (x = i; x < n; ++x) {
        if (s[x] == t[i]) break;
      }
      shift(i);
      shift(n - x);
      shift(n - 1);
      flag = true;
    }
  }
  cout << int(ans.size()) << '\n';
  for (int a : ans) cout << a << ' ';
}
