#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
pair<long long, long long> p;
map<long long, long long> mp;
long long mn = INT_MAX, mx = INT_MIN;
long long n, m, tc, i, j, tmp, sum, cn, ans, res, pos, flag;
string s, s1;
long long a[200007], b[200007];
void swp(long long i, long long pos) {
  for (j = pos - 1; j >= i; j--) {
    v.push_back(j);
    swap(s[j], s[j + 1]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  cin >> s >> s1;
  for (i = 0; i < n; i++) {
    if (s[i] == s1[i]) continue;
    char c = s1[i];
    for (j = i + 1; j < n; j++) {
      if (c == s[j]) {
        pos = j;
        break;
      }
    }
    if (j == n) {
      cout << "-1";
      return 0;
    }
    swp(i, pos);
  }
  cout << v.size() << endl;
  for (auto i : v) cout << i + 1 << " ";
  return 0;
}
