#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string a, b;
  cin >> b >> a;
  map<char, int> m;
  for (auto p : a) m[p]++;
  for (auto p : b) m[p]--;
  for (auto p : m) {
    if (p.second != 0) {
      cout << "-1\n";
      return 0;
    }
  }
  cout << 3 * n << "\n";
  for (int i = 0; i < n; i++) {
    for (int j = n - i - 1; j >= 0; j--) {
      if (b[j] == a[i]) {
        cout << n - j - 1 << " 1 " << n << " ";
        string t = b.substr(j + 1, b.size());
        reverse(t.begin(), t.end());
        string z = b.substr(0, j + 1);
        b = t + z;
        t = string(1, b[b.size() - 1]);
        z = b.substr(0, b.size() - 1);
        b = t + z;
        reverse(b.begin(), b.end());
        break;
      }
    }
  }
  cout << "\n";
}
