#include <bits/stdc++.h>
using namespace std;
void fail(void) {
  cout << -1 << endl;
  exit(0);
}
int n;
vector<int> ops;
string s, t;
string aux;
void shift(int x) {
  rotate(s.begin(), s.begin() + n - x, s.end());
  reverse(s.begin(), s.begin() + x);
  ops.push_back(x);
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s >> t;
  vector<int> freq(26);
  for (int i = (int)(0); i < (int)(n); i++) {
    freq[s[i] - 'a'] += 1;
    freq[t[i] - 'a'] -= 1;
  }
  for (int i = (int)(0); i < (int)(26); i++) {
    if (freq[i] != 0) {
      fail();
    }
  }
  aux = string(n, '*');
  for (int i = (int)(0); i < (int)(n); i++) {
    if (i % 2 == 0) {
      aux[i] = t[n - 1 - i / 2];
    } else {
      aux[i] = t[i / 2];
    }
  }
  reverse(aux.begin(), aux.end());
  for (int i = (int)(0); i < (int)(n); i++) {
    int idx = -1;
    for (int j = (int)(i); j < (int)(n); j++) {
      if (s[j] == aux[i]) {
        idx = j;
        break;
      }
    }
    assert(idx >= 0);
    shift(n - idx - 1);
    shift(idx - i + 1);
    shift(i);
  }
  assert(s == t);
  cout << ops.size() << "\n";
  for (int i = (int)(0); i < (int)(ops.size()); i++) {
    cout << ops[i] << (i == (int)ops.size() - 1 ? "" : " ");
  }
  cout << "\n";
}
