#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n, m;
string S, T;
int cnt[26][2];
vector<int> res;
void shift(int x) {
  res.push_back(x);
  string temp = "";
  for (int i = n - 1; i >= n - x; --i) temp += S[i];
  for (int i = 0; i < n - x; ++i) temp += S[i];
  S = temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  cin >> S >> T;
  for (auto i : S) cnt[i - 'a'][0] += 1;
  for (auto i : T) cnt[i - 'a'][1] += 1;
  for (int i = 0; i <= 25; ++i) {
    if (cnt[i][0] != cnt[i][1]) {
      cout << -1 << '\n';
      return 0;
    }
  }
  reverse(T.begin(), T.end());
  for (int i = 0; i < n; ++i) {
    char need = T[i];
    shift(n);
    for (int j = n - 1 - i; j >= 0; --j) {
      if (j == -1 || S[j] == need) {
        shift(n - 1 - j);
        break;
      }
    }
    shift(1);
  }
  cout << int(res.size()) << '\n';
  for (auto i : res) cout << i << ' ';
  cout << '\n';
  return 0;
}
