#include <bits/stdc++.h>
using namespace std;
int n;
string s, t;
vector<int> moves;
void move_left(int i) {
  if (i == 0) return;
  moves.push_back(n);
  moves.push_back(i);
  moves.push_back(1);
  string B = s.substr(i + 1);
  reverse(B.begin(), B.end());
  s = s[i] + s.substr(0, i) + B;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> s >> t;
  vector<int> f(26);
  for (char ch : s) f[ch - 'a']++;
  for (char ch : t) f[ch - 'a']--;
  for (int i : f) {
    if (i != 0) {
      cout << "-1\n";
      return 0;
    }
  }
  reverse(t.begin(), t.end());
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (t[i] == s[j]) {
        move_left(j);
        break;
      }
    }
  }
  cout << moves.size() << '\n';
  for (int m : moves) cout << m << ' ';
  cout << '\n';
  return 0;
}
