#include <bits/stdc++.h>
using namespace std;
string s, t;
int n;
vector<int> ansvec;
void shift(int x) {
  if (x == 0) return;
  ansvec.push_back(x);
  string str;
  for (int i = n - 1; i >= (n - 1 - x + 1); i--) {
    str += s[i];
    s.erase(s.begin() + i);
  }
  s = str + s;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  cin >> s >> t;
  string s1 = s, s2 = t;
  sort(s1.begin(), s1.end());
  sort(s2.begin(), s2.end());
  if (s1 != s2) return cout << -1, 0;
  int l = n / 2;
  int r = l - 1;
  for (int i = 0; i < s.size(); i++) {
    int len = (r - l + 1);
    shift(len);
    int need = 0;
    if (i % 2 == 0) {
      r++;
      for (int i = n - 1; i >= 0; i--) {
        if (s[i] == t[r]) {
          need = n - i;
          break;
        }
      }
    } else {
      l--;
      for (int i = n - 1; i >= 0; i--) {
        if (s[i] == t[l]) {
          need = n - i;
          break;
        }
      }
    }
    shift(need);
    len++;
    need--;
    shift(n - need - len);
  }
  if (n % 2 == 1) shift(n);
  if (s != t) return cout << -1, 0;
  cout << ansvec.size() << "\n";
  for (int i = 0; i < ansvec.size(); i++) cout << ansvec[i] << ' ';
}
