#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  int n;
  cin >> n >> a >> b;
  int T[n], pom[n];
  for (int i = 0; i < n; ++i) T[i] = -1;
  for (int i = 0; i < n; ++i) {
    bool ud = false;
    for (int j = 0; j < n; ++j) {
      if (T[j] == -1 && a[j] == b[i]) {
        ud = true;
        T[j] = i;
        break;
      }
    }
    if (!ud) {
      cout << -1 << endl;
      return 0;
    }
  }
  queue<int> ans;
  int t = (T[n - 1] == 0 ? n - 1 : n);
  while (t > 0) {
    int np = -1;
    for (int i = 0; i < n; ++i)
      if (T[i] == n - t) {
        np = i;
        break;
      }
    ans.push(n - np - 1);
    ans.push(1);
    ans.push(n);
    int id = 0;
    for (int i = np - 1; i >= 0; --i) {
      pom[id++] = T[i];
    }
    for (int i = np + 1; i < t; ++i) {
      pom[i - 1] = T[i];
    }
    t--;
    for (int i = 0; i < t; ++i) T[i] = pom[i];
    for (int i = t; i < n; ++i) {
      T[i] = i - t;
    }
  }
  cout << ans.size() << endl;
  while (!ans.empty()) {
    cout << ans.front() << " ";
    ans.pop();
  }
  cout << endl;
}
