#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e3 + 5;
char a[N], b[N];
int cnt[26];
int n;
vector<int> ans;
void doThis(int x) {
  ans.push_back(x);
  reverse(a + 1, a + 1 + n);
  reverse(a + 1 + x, a + 1 + n);
}
int main() {
  scanf("%d %s %s", &n, a + 1, b + 1);
  for (int i = 1; i <= n; i++) {
    cnt[a[i] - 'a']++;
    cnt[b[i] - 'a']--;
  }
  for (int i = 0; i < 26; i++) {
    if (cnt[i]) {
      puts("-1");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    int idx = -1;
    for (int j = 1; j <= n + 1 - i; j++) {
      if (a[j] == b[i]) {
        idx = j;
        break;
      }
    }
    doThis(n - idx);
    doThis(1);
    doThis(n - 1);
  }
  cout << ans.size() << endl;
  for (auto x : ans) {
    cout << x << " ";
  }
  cout << endl;
}
