#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
void shift(string &a, int x, int n) {
  string c = a.substr(n - x, x);
  for (int i = n - x, j = n; i >= 0; --i, --j) a[j] = a[i];
  for (int i = 0, j = x - 1; i < x; ++i, --j) a[i] = c[j];
}
void solve(string &a, string &b, int n) {
  int j, pos = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (j = pos; j < n; ++j) {
      if (a[j] == b[i]) break;
    }
    if (j >= n || a[j] != b[i]) {
      cout << "-1\n";
      return;
    }
    shift(a, n, n);
    shift(a, j, n);
    shift(a, 1, n);
    ans.push_back(n);
    ans.push_back(j);
    ans.push_back(1);
    ++pos;
  }
  cout << ans.size() << "\n";
  for (auto x : ans) cout << x << " ";
  cout << "\n";
}
int main() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  solve(a, b, n);
  return 0;
}
