#include <bits/stdc++.h>
using namespace std;
long long int fastexpo(int base, int power, long long int mod) {
  if (power == 1)
    return base % mod;
  else if (power == 0)
    return 1;
  long long int temp = ((fastexpo(base, power / 2, mod)) % mod);
  if (!(power & 1))
    return (temp * temp) % mod;
  else
    return ((((temp * temp) % mod) * (base % mod)) % mod);
}
void swap(int &a, int &b) {
  int temp = a;
  a = b;
  b = temp;
  return;
}
void printarr(int *arr, int n) {
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  printf("\n");
}
int main() {
  int n, flag = 0, ans = 0, temp_index;
  vector<int> arr;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i < n; i++) {
    if (s[i] == t[i])
      continue;
    else {
      temp_index = -1;
      for (int j = i + 1; j < n; j++)
        if (s[j] == t[i]) temp_index = j;
      if (temp_index == -1) {
        flag = 1;
        break;
      }
      ans += temp_index - i;
      for (int j = temp_index - 1; j >= i; j--) {
        arr.push_back(j);
        swap(s[j], s[j + 1]);
      }
      s[i] = t[i];
    }
  }
  if (flag)
    cout << "-1" << endl;
  else {
    printf("%d ", ans);
    printf("\n");
    for (int i = 0; i < ans; i++) printf("%d ", arr[i] + 1);
    printf("\n");
  }
  return 0;
}
