#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int N = 1e5 + 10;
string s, t;
int n;
void Shift(int x) {
  string tmp(n, ' ');
  for (int i = 0; i < n - x; ++i) tmp[i + x] = s[i];
  for (int i = 0; i < x; ++i) tmp[i] = s[n - 1 - i];
  s = tmp;
}
void solve() {
  cin >> n >> s >> t;
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    int p = -1;
    for (int j = 0; j < n - i; ++j) {
      if (s[j] == t[i]) {
        p = j;
        break;
      }
    }
    if (p == -1) {
      cout << -1 << endl;
      return;
    }
    if (p < n - 1) {
      ans.push_back(n - 1 - p);
      Shift(n - p - 1);
    }
    ans.push_back(1);
    Shift(1);
    ans.push_back(n);
    Shift(n);
  }
  cout << ans.size() << endl;
  for (int x : ans) cout << x << " ";
  cout << endl;
}
int main() {
  solve();
  return 0;
}
