#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
inline void cmin(int &x, int y) {
  if (y < x) x = y;
}
inline void cmax(int &x, int y) {
  if (y > x) x = y;
}
int a[26], b[26];
int n;
string s, t;
vector<int> ans;
int main() {
  cin >> n >> s >> t;
  for (int i = 0; i < n; i++) {
    a[s[i] - 'a']++;
    b[t[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++)
    if (a[i] != b[i]) return !printf("-1");
  int f = -2;
  for (int i = n - 1; i >= 0; i--) {
    ++f;
    int k1;
    char c = t[i];
    string a = "", br = "";
    for (int j = 0; j < n; ++j) {
      if (s[j] == c && j > f) {
        k1 = j;
        for (int k = n - 1; k > j; --k) br += s[k];
        break;
      }
      a += s[j];
    }
    string temp;
    temp += c;
    temp += a;
    temp += br;
    s = temp;
    ans.push_back(n);
    ans.push_back(k1);
    ans.push_back(1);
  }
  printf("%d\n", ans.size());
  for (int x : ans) printf("%d ", x);
  return 0;
}
