Submit: 1055 Solved: 461

[Submit][Status][Web Board]

You are given the pre-order and in order traversal of the binary tree, please find the post-order of this tree.

The first line will be an integer \(T (1 \leq T \leq 10)\), which is the number of test cases.

For each test data:

The first line contains one integer \(N (1 \leq N \leq 10^3)\) — the number of nodes of the tree

Then follows two lines:

The first line contains N integers ranging from 1 to N, indicating the pre-order traversal of the tree.

The second line contains N integers ranging from 1 to N, indicating the in-order traversal of the tree.

For each test data:

The first line contains one integer \(N (1 \leq N \leq 10^3)\) — the number of nodes of the tree

Then follows two lines:

The first line contains N integers ranging from 1 to N, indicating the pre-order traversal of the tree.

The second line contains N integers ranging from 1 to N, indicating the in-order traversal of the tree.

For each case, contains one line with N integer, the post-order traversal of the tree.

```
1
5
1 2 4 3 5
2 4 1 5 3
```

`4 2 5 3 1`