#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;
vector<int> do_shift(int x, vector<int> nums) {
  vector<int> ret;
  int n = (int)(nums).size();
  for (int i = n - 1; i >= n - x; i--) ret.push_back(nums[i]);
  for (int i = 0; i < n - x; i++) ret.push_back(nums[i]);
  return ret;
}
int vec_find(vector<int>& nums, int x) {
  for (int i = 0; i < (int)(nums).size(); i++) {
    if (nums[i] == x) return i;
  }
  assert(false);
  return (int)(nums).size();
}
vector<int> do_sort(vector<int> nums) {
  vector<int> ops;
  int n = (int)(nums).size();
  for (int i = 0; i < n; i += 2) {
    int pos = vec_find(nums, i);
    ops.push_back(n - pos - 1);
    nums = do_shift(n - pos - 1, nums);
    ;
    ops.push_back(1);
    nums = do_shift(1, nums);
    ;
    if (i + 1 == n) {
      ops.push_back(n);
      nums = do_shift(n, nums);
      ;
      break;
    }
    pos = vec_find(nums, i + 1);
    ops.push_back(n - pos);
    nums = do_shift(n - pos, nums);
    ;
    ops.push_back(n);
    nums = do_shift(n, nums);
    ;
    pos = vec_find(nums, i + 1);
    ops.push_back(n - pos - 1);
    nums = do_shift(n - pos - 1, nums);
    ;
  }
  return ops;
}
int32_t main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<int> s_nums(n, 0);
  for (int i = 0; i < n; i++) {
    int pos = s.find(t[i]);
    if (pos == string::npos) {
      cout << -1 << endl;
      return 0;
    }
    s_nums[pos] = i;
    s[pos] = 'X';
  };
  vector<int> ops = do_sort(s_nums);
  cout << (int)(ops).size() << endl;
  for (int x : ops) {
    cout << x << " ";
  }
  cout << endl;
  return 0;
}
