#include <bits/stdc++.h>
using namespace std;
int n;
string s, t;
map<char, int> ca, cb;
vector<int> ses;
void shift(int x) {
  ses.push_back(x);
  reverse(s.begin(), s.begin() + n);
  if (x < n) reverse(s.begin() + x, s.begin() + n);
}
int main() {
  cin >> n >> s >> t;
  for (auto ch : s) {
    ca[ch]++;
  }
  for (auto ch : t) {
    cb[ch]++;
  }
  if (ca != cb) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    char ch = t[n - 1 - i];
    int pos = -1;
    for (int j = n - 1; j >= i; j--) {
      if (s[j] == ch) {
        pos = j;
        break;
      }
    }
    shift(n);
    shift(pos);
    shift(1);
  }
  cout << ses.size() << endl;
  for (auto x : ses) {
    cout << x << " ";
  }
  cout << endl;
  return 0;
}
