#include <bits/stdc++.h>
using namespace std;
long long int n;
string s, t;
vector<long long int> ans;
long long int a[200];
int main() {
  cin >> n;
  cin >> s >> t;
  for (auto j : s) a[j]++;
  for (auto j : t) a[j]--;
  if (*max_element(a, a + 200) != 0 || *min_element(a, a + 200) != 0)
    return cout << -1 << '\n', 0;
  for (int i = 0; i < n; i++) {
    long long int k = -1;
    for (int j = n - i - 1; j >= 0; j--) {
      if (s[j] == t[i]) {
        k = j;
        break;
      }
    }
    reverse(s.begin(), s.begin() + k + 1);
    reverse(s.begin(), s.end());
    ans.push_back(n - k - 1);
    reverse(s.begin(), s.begin() + n - 2 + 1);
    reverse(s.begin(), s.end());
    ans.push_back(1);
    reverse(s.begin(), s.begin() + 0 + 1);
    reverse(s.begin(), s.end());
    ans.push_back(n - 1);
  }
  cout << ans.size() << '\n';
  for (auto j : ans) cout << j << " ";
  cout << '\n';
  return 0;
}
