There are N friends sitting in a circle, they are numbered clockwise 1 to N. Game starts with Player 1 receiving the ball. A player needs to pass the ball to other player based on some conditions
If he is receiving ball for pth time , he passes that ball to person L places to left if p is even or L places right if p is odd.
If any player receives the ball M times then game is over. Given the values of N , L and M, you have to tell the number of times the ball is passed among players.
Input Format
First input is number of players(N) 3<=N<=1000
Second input is maximum number of times a player receive ball(M) 3<=M<=1000
Third input is a number(L)
Output Format
Print the number of times the ball is passed among players. In case of any invalid input, the print -1.
First, player 1 gets the ball. Since he has held the ball 1 time, he passes the ball to player 4, who is two places to his right. This is player 4's first time holding the ball, so he gives it to player 2, who passes it to player 5. Player 5 then passes the ball to player 3, who passes it back to player 1. Since player 1 has now held the ball 2 times, he passes it to player 3, who passes it to player 5, who then passes the ball to player 2. Finally, player 2 passes the ball to player 4, who then passes it to player 1. Player 1 has now held the ball 3 times, and the game ends.