Problem1268--还原二叉树I

1268: 还原二叉树I

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 802  Solved: 456
[Submit] [Status] [Web Board] [Creator:]

Description

PIPI现在有两个序列,分别为二叉树的先序序列和二叉树的中序序列,他想由这两个序列还原二叉树,你能帮PIPI还原吗?

Input

第一行输入序列的长度n (0<n<100).
第二行输入二叉树的先序序列。
第三行输入二叉树的中序序列。

Output

输出二叉树的后序遍历序列。

Sample Input

6
1 2 3 4 5 6
3 2 4 1 6 5

Sample Output

3 4 2 6 5 1

Source/Category