#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 5;
string s, t, tmp;
int n, vis[2][26];
int main() {
  cin >> n;
  cin >> s >> t;
  for (int i = 0; i < n; i++) vis[0][s[i] - 'a']++, vis[1][t[i] - 'a']++;
  for (int i = 0; i < 26; i++)
    if (vis[0][i] != vis[1][i]) {
      printf("-1\n");
      exit(0);
    }
  cout << 3 * n << "\n";
  int j = 0;
  for (int i = n - 1, lev = 0; i >= 0; i--, lev++) {
    cout << n << "\n";
    for (j = lev; j < n; j++)
      if (s[j] == t[i]) {
        cout << j << "\n";
        break;
      }
    reverse(s.begin(), s.end());
    tmp = s.substr(n - j, j);
    reverse(tmp.begin(), tmp.end());
    s = s.substr(0, n - j);
    s = tmp + s;
    cout << "1\n";
    tmp = s.substr(n - 1, 1);
    s = s.substr(0, n - 1);
    s = tmp + s;
  }
  return 0;
}
