There are
Each boy has his own preference order of all
As you are a well-known matching master, they wish that you find a stable matching for them!
The first line includes one integer
The next line contains
The next line contains
For the next
For the next
It is guaranteed that no two person share a same name.
Your program should output
Each line contains a boy's name and a girl's name separated by a space, representing a pair in the matching. Please output the boy's name before the girl.
You must make sure that your solution is a stable matching.
If there are multiple solution, output any one.
3
A B C
a b c
b a c
b a c
b c a
C B A
B C A
A C B
A a
B b
C c
For
$N≤100$
For 100% testcases:
$1≤N≤1000$ - length of any name is a positive integer no more than 10