#include <bits/stdc++.h>
using namespace std;
int A[30];
vector<int> mov;
void change(string &c) {
  for (int i = 0; i < mov.size(); ++i) {
    string temp2 = "";
    for (int j = 0; j < c.size() - mov[i]; ++j) {
      temp2 += c[j];
    }
    string temp = "";
    for (int k = 0; k < mov[i]; ++k) {
      temp += c[c.size() - k - 1];
    }
    temp += temp2;
    c = temp;
  }
}
int khoj[2005];
void work(int n) {
  vector<int> temp;
  temp.clear();
  for (int i = 1; i <= n; ++i) {
    reverse(temp.begin(), temp.end());
    temp.push_back(i - 1);
  }
  for (int i = 0; i < temp.size(); ++i) {
    khoj[temp[i]] = i;
  }
}
int main() {
  int n;
  cin >> n;
  string a, b;
  work(n);
  cin >> a >> b;
  string kutta = "";
  for (int i = 0; i < b.size(); ++i) {
    kutta += b[khoj[i]];
  }
  b = kutta;
  string c = a;
  for (int i = 0; i < n; ++i) {
    ++A[a[i] - 'a'];
  }
  for (int i = 0; i < n; ++i) {
    --A[b[i] - 'a'];
  }
  for (int i = 0; i < 26; ++i) {
    if (A[i] != 0) {
      cout << "-1" << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    int s = 0;
    int ind;
    string bor = "";
    for (int j = i; j < n; ++j) {
      if (a[j] == b[i]) {
        ind = j;
        break;
      }
      bor += a[j];
      ++s;
    }
    mov.push_back(n - ind);
    mov.push_back(s);
    mov.push_back(i + 1);
    string temp = "";
    for (int j = 0; j <= i; ++j) {
      temp += b[j];
    }
    reverse(bor.begin(), bor.end());
    temp += bor;
    for (int j = n - 1; j > ind; --j) temp += a[j];
    a = temp;
  }
  cout << mov.size() << endl;
  for (int i = 0; i < mov.size(); ++i) {
    printf("%d ", mov[i]);
  }
  cout << endl;
  return 0;
}
