#include <bits/stdc++.h>
using namespace std;
const int mx = 6e3 + 60;
const int MOD = 1e9 + 7;
int n, k, ans[mx];
string str, target;
void pop() {
  ans[k++] = 1;
  char ch = str.back();
  str.erase(str.end() - 1);
  str.insert(str.begin(), ch);
}
void revSuffix(int len) {
  if (len <= 1) return;
  ans[k++] = n;
  ans[k++] = n - len;
  reverse(str.begin() + n - len, str.end());
}
void solve() {
  for (int i = n - 1; i >= 0; i--) {
    int j = n - 1;
    while (j >= 0 && str[j] != target[i]) j--;
    if (j < 0) {
      k = -1;
      return;
    }
    revSuffix(n - j);
    pop();
  }
  if (str != target) k = -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> str >> target;
  solve();
  cout << k << endl;
  for (int i = 0; i < k; i++) cout << ans[i] << ' ';
  cout << endl;
  return 0;
}
