#include <bits/stdc++.h>
const long long iinf = INT64_MAX - 1;
const int inf = INT32_MAX - 1;
const int MOD = (1e6 + 3);
int dir4[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int dir8[8][2] = {{1, 0}, {-1, 0}, {0, 1},  {0, -1},
                  {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
int knight[8][2] = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},
                    {1, 2}, {-1, 2}, {1, -2}, {-1, -2}};
bool check(int n, int pos) { return n & (1 << pos); }
using namespace std;
void solve() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    if (s[i] == t[i]) continue;
    int j = i;
    while (t[i] != s[j] && j < n) j++;
    if (j == n) {
      cout << -1;
      return;
    }
    while (j > i) {
      swap(s[j - 1], s[j]);
      ans.push_back(j);
      j--;
    }
  }
  cout << ans.size() << '\n';
  for (int a : ans) cout << a << " ";
}
int main() {
  int t = 1;
  if (0) cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
