n = int(input())
src, tar = input(), input()
ans = []
def shift(s, x):
ans.append(x)
return s[-x:][::-1] + s[:-x]
flag = True
for i in range(n):
index = -1
for j in range(n-i):
if src[j] == tar[i]:
index = j
break
if index == -1:
flag = False
break
if index == n-1:
continue
src = shift(src, n - index - 1)
src = shift(src, 1)
src = shift(src, n)
if flag:
ans = [str(x) for x in ans]
print(len(ans))
print(' '.join(ans))
else:
print(-1)
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |