#include <bits/stdc++.h>
using namespace std;
string a, b;
int n;
void check() {
  int cnta[26], cntb[26];
  memset(cnta, 0, sizeof(cnta));
  memset(cntb, 0, sizeof(cntb));
  for (int i = (0); i < ((int)a.size()); ++i) ++cnta[a[i] - 'a'];
  for (int i = (0); i < ((int)b.size()); ++i) ++cntb[b[i] - 'a'];
  for (int i = (0); i < (26); ++i)
    if (cnta[i] != cntb[i]) {
      cout << -1;
      exit(0);
    }
}
vector<int> sol;
void postavi(int x) {
  char let = b[x];
  int pos;
  for (int i = (a.size() - x - 1); i < (a.size()); ++i) {
    if (a[i] == let) {
      pos = i;
      break;
    }
  }
  if (pos == 0) return;
  sol.push_back(n);
  sol.push_back(pos);
  sol.push_back(1);
  reverse(a.begin(), a.end());
  pos = n - pos - 1;
  string A = a.substr(0, pos + 1);
  string B = a.substr(pos + 1, n - pos);
  reverse(B.begin(), B.end());
  a = B + A;
  A = a.substr(0, a.size() - 1);
  B = a[a.size() - 1];
  a = B + A;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  cin >> a >> b;
  check();
  for (int i = n - 1; i >= 0; --i) postavi(i);
  cout << sol.size() << "\n";
  for (auto it : sol) cout << it << " ";
}
