#include <bits/stdc++.h>
using namespace std;
int n;
string s, t, a, b;
vector<int> res;
bool ana(string a, string b) {
  sort(a.begin(), a.end()), sort(b.begin(), b.end());
  return a == b;
}
void shift(int x) {
  res.push_back(x);
  for (int i = 0; i < x; i++) a[i] = s[n - i - 1];
  for (int i = x; i < n; i++) a[i] = s[i - x];
  swap(a, s);
}
int f1(int i) {
  int j = i;
  while (s[j] != t[i]) j++;
  shift(n - j);
  return j - i;
}
void f2(int i) { shift(i); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> s >> t;
  if (!ana(s, t)) {
    cout << -1 << '\n';
    return 0;
  }
  b.resize(n);
  int k = 0;
  for (int i = n - 2; i >= 0; i -= 2) b[i] = t[k++];
  for (int i = 1 - n % 2; i < n; i += 2) b[i] = t[k++];
  swap(b, t);
  a.resize(n);
  for (int i = 0; i < n; i++) {
    int j = f1(i);
    f2(j);
    shift(n);
  }
  cout << res.size() << '\n';
  for (int x : res) cout << x << " ";
  cout << '\n';
  return 0;
}
