#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3;
string s, t;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  cin >> s >> t;
  for (int i = n - 1; i >= 0; i--) {
    int j = n - i - 1;
    while (j < n && s[j] != t[i]) j++;
    if (j == n) {
      cout << -1;
      return 0;
    }
    v.push_back(n);
    v.push_back(j);
    v.push_back(1);
    reverse(s.begin() + j, s.end());
    reverse(s.begin(), s.end());
    reverse(s.begin() + 1, s.end());
  }
  cout << v.size() << endl;
  for (auto a : v) cout << a << ' ';
}
