#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, U b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, U b) {     if (a < b) a = b;   }   template <class T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T, class T1>   inline void gn(T &first, T1 &second) {     gn(first);     gn(second);   }   template <class T, class T1, class T2>   inline void gn(T &first, T1 &second, T2 &z) {     gn(first);     gn(second);     gn(z);   }   template <class T>   inline void print(T first) {     if (first < 0) {       putchar( - );       return print(-first);     }     if (first < 10) {       putchar( 0  + first);       return;     }     print(first / 10);     putchar(first % 10 +  0 );   }   template <class T>   inline void printsp(T first) {     print(first);     putchar(   );   }   template <class T>   inline void println(T first) {     print(first);     putchar(  n );   }   template <class T, class U>   inline void print(T first, U second) {     printsp(first);     println(second);   }   template <class T, class U, class V>   inline void print(T first, U second, V z) {     printsp(first);     printsp(second);     println(z);   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   int fail[101010];   char s[101010], s1[101010], t[101010], t1[101010], s2[101010];   void build_fail_function(char B[], int len) {     int j = fail[0] = -1;     for (int i = 1; i < len; i++) {       while (j != -1 and B[j + 1] != B[i]) j = fail[j];       if (B[j + 1] == B[i]) j++;       fail[i] = j;     }   }   int main() {     int n;     gn(n);     scanf( %s%s , s, t);     strcpy(s1, s);     strcpy(t1, t);     sort(s1, s1 + n);     sort(t1, t1 + n);     if (strcmp(s1, t1)) return puts( -1 ), 0;     int now = 0, m;     vector<int> ans;     char *p, *q;     while (now < n) {       while (now < n && s[now] == t[now]) now++;       q = s + now;       m = n - now;       p = t + now;       build_fail_function(p, m);       int j = -1, res = 0, k = -1;       for (int i = 0; i < m; i++) {         while (j != -1 and p[j + 1] != q[i]) j = fail[j];         if (p[j + 1] == q[i]) j++;         if (res < j + 1) res = j + 1, k = i;         if (j == m - 1) j = fail[j];       }       int A = now, B = k + 1 - res, C = res, D = n - A - B - C;       ans.push_back(n);       if (A + B) ans.push_back(A + B);       ans.push_back(n);       if (A) ans.push_back(A);       for (int i = 0; i < B; i++) s1[i] = q[B - 1 - i];       s1[B] = 0;       for (int i = 0; i < D; i++) t1[i] = q[i + k + 1];       t1[D] = 0;       for (int i = 0; i < C; i++) s2[i] = q[k - res + 1 + i];       s2[C] = 0;       for (int i = 0; i < C; i++) *q = s2[i], q++;       for (int i = 0; i < D; i++) *q = t1[i], q++;       for (int i = 0; i < B; i++) *q = s1[i], q++;       now += res;     }     println(ans.size());     for (int i = 0; i < ans.size(); i++) printsp(ans[i]);     puts(  );     assert(strcmp(s, t) == 0);     return 0;   }