Kernel Knights
Jousting is a medieval contest that involves people on horseback trying to strike each other with wooden lances while riding at high speed. A total of knights have entered a jousting tournament — knights from each of the two great rival houses. Upon arrival, each knight has challenged a single knight from the other house to a duel.
A kernel is defined as some subset of knights with the following two properties:
No knight in was challenged by another knight in .
Every knight not in was challenged by some knight in .
Given the set of the challenges issued, find one kernel. It is guaranteed that a kernel always exists.
Input
The first line contains an integer — the number of knights of each house. The knights from the first house are denoted with integers through , knights from the second house with integers through .
The following line contains integers — the -th integer is the index of the knight challenged by knight .
The following line contains integers — the -th integer is the index of the knight challenged by knight .
Output
Output the indices of the knights in the kernel on a single line. If there is more than one solution, you may output any one.