Yellovball Rotation
There is a sport named Yellovball in Akamanja country. It takes 6 players in each side for a match. They stand in the pitch in two rows, 3 in each rows. The players change their position in such a way that their formation rotates counter-clockwise. For example, A,B,C,D,E,F denotes 6 players in a team. Initially they are standing as
ABC
FED
after a rotation their position will end up like
BCD
AFE
after another rotation their position will end up like
CDE
BAF
The conditions for rotation are
- One team plays the ball first. If they gets point then they play the ball again.
- If they lose point to their opponent, the opponent have to rotate their position anti-clockwise once and the opponent have to play the ball to again.
- Similarly, if the opponent plays the ball this time and wins a point, they have to play the ball next time and if the opponent lose the point, the first team have to rotate.
Game ends when a team takes 5 points first. You will be given multiple state of the game where each state is shown when any of the two teams takes a point. The output will be the winner of the game and their position in rotation after winning the game.
Input
- The first line of input contains two integers n and t. n denotes the team which plays the ball first. n = 1 for the first team plays the ball first and n = 2 for the second team plays the ball at the starting of the game.
- t denotes the number of states of the game where any of the two team gets point till anyone wins
- Then t line follows where each line contains two integer x and y. x denotes the current point of team1 at that state and y denotes the current point of team2.
Output
- First line of the output is winner of the game. 1 if team1 wins and 2 if team2 wins
- Second and third line of the output is the position of the players of the winning team as two string in two lines. Initially six players are positioned as
ABC
FED