#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
int n, a[N], p[N], pos[N];
vector<int> c[26], ans;
string s, t;
void add(int x) {
  if (0 < x) {
    ans.push_back(x);
  }
  vector<int> nw;
  for (int i = n - 1; i >= n - x; --i) {
    nw.push_back(p[i]);
  }
  for (int i = n - 1; i >= x; --i) {
    p[i] = p[i - x];
  }
  for (int i = 0; i < x; ++i) {
    p[i] = nw[i];
  }
  for (int i = 0; i < n; ++i) {
    pos[p[i]] = i;
  }
}
int main() {
  cin >> n >> s >> t;
  for (int i = 0; i < n; ++i) {
    c[t[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    int ind = s[i] - 'a';
    if (c[ind].size() == 0) {
      puts("-1");
      return 0;
    }
    p[i] = c[ind].back();
    c[ind].pop_back();
    pos[p[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    add(n - pos[i] - 1);
    add(1);
    add(n);
  }
  cout << ans.size() << '\n';
  for (int i : ans) cout << i << ' ';
  return 0;
}
