Who is The Naag King ?
Battle between two mighty programmers from BRACU. Who is better? Jaber Vai or Mukhter Vai?
They are very good friends since the beginning of their BRACU life. Though their fan base always quarrel over who is the better among these two? So, Jaber vai and Mukhtar vai thought it should come to an end, as contestants spend lots of their valuable time arguing on this issue instead of focusing on problem solving. As their programming skill is almost the same, it’s difficult to find out who is better through programming battle. So they have decided they will sit for a game named Shap-ludu, seems familiar? Yeah, we used to play Shap ludu a lot in our childhood.
The long awaited day has finally arrived. Everyone is too excited to witness the battle. BUT ALAS !! You fall sick on that day, and couldn’t come to the campus. As a result, you came up with an idea; you have chosen one of your friends who will give you the live update of every move of each player. Can you determine who is the winner calculating each of their moves?
Rules of the Game:
a. Game Board: The board is a 10×10 matrix. The squares are numbered from 1 to 100 sequentially, will consist of some ladders and snakes. (See the given picture.)
b. Jaber Vai will always play the first move.
c. Player until getting ‘1’ on their dice can’t move their piece. After getting ‘1’ on the dice, one should put his piece on square numbered ‘1’.
d. In each turn, every player will roll the dice only once.
e. Take it in turns to roll the dice. Move your piece forward the number of spaces shown on the dice.
f. If your piece lands at the bottom of a ladder, you should move up to the top of the ladder.
g. If your piece lands on the head of a snake, you must slide down to the bottom of the snake.
h. The first player to get to the square ‘100’ is the winner.
The first line of the input contains two integers L (0≤L≤50) and S (0≤S≤75) denoting the number of Ladders and Snake in the board, respectively .
The next L lines contain description of the ladder: the ith of them contains two integers X and Y (1≤X,Y≤100,X≺Y) denoting the start and end positions of a ladder, means if you come to the square numbered X, the ladder will take you to the square numbered Y.
The next S lines contain description of the ladder: the ith of them contains two integers P and Q (1 < P < 100 , P>Q) denoting the start and end positions of a Snake, means if you come to the square numbered P, at the mouth of a snake, then you have to move your piece to the square numbered Q.
The next lines contain V (1≤V≤6),digit came up on the dice. V1 is the move of Jaber Vai, V2 denotes the move of Mukhtar vai, V3 is the move of Jaber vai and so on. The input will be terminated when we will get the winner.
You have to print the name who won the battle, calculating their moves. If Jaber Vai wins, you should print “Jaber Tuhin is the winner.” or else “Mukhter Hossain is the winner.” (without quotes). It is guaranteed that one of the players will obviously win the game.
7 5 5 26 13 56 18 39 37 62 48 72 60 98 65 95 23 7 44 14 33 9 68 25 94 70 5 2 5 1 1 6 4 2 6 4 1 4 4 3 1 6 1 2
Mukhter Hossain is the winner.
Jaber Vai will always give the first move. They have rolled the dice alternatively .
Moves of Jaber Vai : 5 (need 1 to start), 5 (need 1 to start), 1 ( put his piece on 1st square ), 4 (moved to 5, climbing the ladder reached 26 ), 6 ( moved to 32 ), 1 ( moved to 33, where he found a snake, had to take his piece at square 9), 4 ( went to 13, found a ladder, climbing the ladder reached 56 ), 1 ( moved to 57 ), 1 ( moved to 58 )
Moves of Mukhter Vai : 2 ( need 1 to start ) , 1 ( put his piece on 1st square ), 6 ( went to 7 ), 2 ( went to 9 ), 4 ( went to 13, found a ladder, climbing the ladder reached 56 ), 4 ( went to 60, found a ladder, climbing the ladder reached 98 ), 3 ( invlid move ), 6 ( invalid move ), 2 ( reach square 100, winner of the match )