#include <bits/stdc++.h>
using namespace std;
vector<int> res;
string s, t;
int main() {
  cin >> s >> s >> t;
  string s2 = s, t2 = t;
  sort(s2.begin(), s2.end());
  sort(t2.begin(), t2.end());
  if (s2 != t2) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < (int)t.size(); ++i) {
    for (int j = i; j < (int)s.size(); ++j) {
      if (t[(int)t.size() - i - 1] == s[j]) {
        res.push_back((int)s.size());
        res.push_back(j);
        res.push_back(1);
        reverse(s.begin() + j, s.end());
        rotate(s.begin(), s.begin() + s.size() - 1, s.end());
        break;
      }
    }
  }
  cout << res.size() << endl;
  for (auto i : res) cout << i << " ";
  return 0;
}
