#include <bits/stdc++.h>
using namespace std;
vector<int> rez;
int n;
string a, b, s1, s2;
int main() {
  cin >> n;
  cin >> a >> b;
  s1 = a;
  sort(s1.begin(), s1.end());
  s2 = b;
  sort(s2.begin(), s2.end());
  if (s1 != s2) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (b[n - 1 - i] == a[j]) {
        rez.push_back(n);
        rez.push_back(j);
        rez.push_back(1);
        reverse(a.begin() + j, a.end());
        rotate(a.begin(), a.end() - 1, a.end());
        break;
      }
    }
  }
  cout << rez.size() << endl;
  for (auto v : rez) cout << v << " ";
  return 0;
}
