#include <bits/stdc++.h>
using namespace std;
int n;
string s1, s2;
int cnt[40];
vector<int> jaw;
int main() {
  cin >> n >> s1 >> s2;
  if (s1 == s2) {
    cout << 0 << endl;
    return 0;
  }
  for (char i : s1) cnt[i - 'a']++;
  for (char i : s2) cnt[i - 'a']--;
  for (char i : s1) {
    if (cnt[i - 'a'] != 0) {
      cout << "-1\n";
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s1[0] == s2[i]) {
      jaw.push_back(n - i - 1);
      string sem = "";
      sem += s1[i];
      for (int j = n - 1; j > i; j--) {
        sem += s1[j];
      }
      for (int j = 0; j < i; j++) {
        sem += s1[j];
      }
      jaw.push_back(1);
      reverse(sem.begin(), sem.end());
      jaw.push_back(n);
      s1 = sem;
      break;
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (s2[i] != s1[j]) continue;
      jaw.push_back(n - j - 1);
      string sem = "";
      sem += s1[j];
      for (int k = n - 1; k > j; k--) sem += s1[k];
      for (int k = 0; k < j; k++) sem += s1[k];
      jaw.push_back(1);
      reverse(sem.begin(), sem.end());
      jaw.push_back(n);
      s1 = sem;
      break;
    }
  }
  cout << jaw.size() << endl;
  for (int i : jaw) cout << i << ' ';
  cout << endl;
}
