#include <bits/stdc++.h>
const double pi = acos(-1.0);
const double eps = 1e-9;
using namespace std;
int n;
string s, t;
vector<int> ans;
void shift(int x) {
  ans.push_back(x);
  string res;
  for (int i = (int)s.size() - 1; i >= (int)s.size() - x; i--) {
    res.push_back(s[i]);
  }
  for (int i = 0; i < (int)s.size() - x; i++) {
    res.push_back(s[i]);
  }
  s = res;
}
bool ok(string a, string b) {
  sort((a).begin(), (a).end());
  sort((b).begin(), (b).end());
  return (a == b);
}
void solve() {
  cin >> n;
  cin >> s >> t;
  if (!ok(s, t)) {
    cout << "-1" << endl;
    return;
  }
  int idt = n - 1;
  int can = 0;
  while (1) {
    if (s == t) {
      break;
    }
    int id;
    for (int i = can; i < n; i++) {
      if (s[i] == t[idt]) {
        id = i;
        break;
      }
    }
    shift(n);
    shift(id);
    shift(1);
    can++;
    idt--;
    if (idt < 0) {
      break;
    }
  }
  cout << ans.size() << endl;
  for (int x : ans) {
    cout << x << " ";
  }
}
int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(6);
  int step = 1;
  for (int i = 0; i < step; i++) {
    solve();
  }
}
