
ZOJ Problem Set  3938
The bomb is about to explode! Please defuse it as soon as possible! There is a display showing a number from 1 to 4 on the bomb. Besides this, there are 4 buttons under the display. Each button is labeled by a number from 1 to 4. The numbers on the buttons are always distinct. There are 5 defusing stages in total. Pressing the correct button can progress the bomb to the next defusing stage. The number on the display and the number on each button may be different in different stages. The bomb will be defused only when all 5 defusing stages get passed. Pressing the incorrect button will cause the bomb to explode immediately. Be careful! Here is the detailed bomb defusing manual. Button positions are ordered from left to right. Stage 1:
Stage 2:
Stage 3:
Stage 4:
Stage 5:
InputThere are multiple test cases. The first line of input is an integer T indicating the number of test cases. For each test case: There are 5 lines. Each line contains 5 integers D, B_{1}, B_{2}, B_{3}, B_{4} indicating the number on the display and the numbers on the buttons respectively. The ith line correspond to the ith stage. OutputFor each test case, output 5 lines. The ith line contains two integers indicating the position and the label of the correct button for the ith stage. Sample Input1 4 2 1 3 4 2 2 4 3 1 4 3 1 4 2 4 3 4 2 1 2 3 1 2 4 Sample Output4 4 4 1 3 4 4 1 2 1 HintKeep talking with your teammates and nobody explodes! Author: JIANG, Kai Source: The 13th Zhejiang Provincial Collegiate Programming Contest 