Josh, Nils, and Mike are on a heist!
They have already broken into
Josh, Nils, and Mike coordinated their heist, so for every bank, each person went to a different room and performed exactly
In one move, Josh took exactly two treasures from vault
and put one treasure into vault , where .In one move, Nils took exactly two treasures from vault
and put one treasure into vault , where .In one move, Mike took either one or two treasures from any vault
, where .
Of course, the number of treasures taken from a vault in one move could not exceed the number of treasures already in that vault.
Knowing this and given the final states of each vault inside of each room, can you help figure out which person broke into which room for each bank? Note that since they disabled the security cameras, you do not know the value of
Constraints
It is guaranteed that each vault initially had no more than
It is guaranteed that the input is valid. (Originally,
The sum of
Subtask 1 [15%]
Subtask 2 [15%]
For every move, Mike is guaranteed to have removed two treasures.
Subtask 3 [70%]
No additional constraints.
Input Specification
The first line contains an integer
The next
The second line contains
The third line contains
The fourth line contains
Output Specification
For each bank, on a separate line, output the names Josh
, Nils
, and Mike
in an order corresponding to who broke into the first, second and third rooms respectively. If there are multiple possible valid orders, output any of them.
Sample Input
2
5
4 4 0 7 3
3 6 2 6 0
4 7 2 5 0
2
999999999 0
0 999999999
666666666 0
Sample Output
Nils Mike Josh
Josh Nils Mike
Explanation
Originally, the treasures inside the vaults of each room in bank
In the first room, Nils took two treasures from vault
In the second room, Mike took one treasure from vault
In the third room, Josh took two treasures from vault
Comments