题号:NC211818
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld
题目描述
Given two

permutations

, you should construct an unrooted tree

, which satisfies that

is a possible topological order of

if

is made the root, and that

is a possible dfs order of

if

is made the root.
Here, a permutation

of size

is a valid topological order of a rooted tree

of size

iff that for all edges in

, the parent nodes are at front of the child nodes in permutation

.
输入描述:
The first line contains one integer
, denoting the size of permutations.
The second line contains
integers
, denoting permutation
.
The third line contains
integers
, denoting permutation
.
输出描述:
If solution exists, print "YES" in one line, and following
lines each contains two integers
, denoting one edge in
. If multiple solutions exist, print any one of them. If no solution, print "NO" in one line.