#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 5e6 + 7;
string s1, s2;
int cnt = 0, ans[N], n;
void change(int j) {
  string temp = s1;
  int id = 0;
  for (int i = j - 1; i >= 0; i--) s1[id++] = temp[i];
  for (int i = j + 1; i < n; i++) s1[id++] = temp[i];
  s1[id++] = temp[j];
  s1[id] = '\0';
}
signed main() {
  ios::sync_with_stdio(false);
  cin >> n;
  cin >> s1 >> s2;
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n - i; j++)
      if (s1[j] == s2[i]) break;
    if (j == n - i) return cout << "-1\n", 0;
    change(j);
    ans[++cnt] = n - j - 1;
    ans[++cnt] = 1;
    ans[++cnt] = n;
  }
  cout << cnt << "\n";
  for (int i = 1; i <= cnt; i++) cout << ans[i] << " ";
  cout << "\n";
}
