Two friends, A and B, are playing the game of matchsticks. In this game, a group of matchsticks is placed on the table. The players can pick any number of matchsticks from 1 to 4 (both inclusive) during their chance. The player who takes the last match stick wins the game. If A starts first, how many matchsticks should he pick such that he is guaranteed to win the game.
Note : Consider the game is played optimally.
The first line of input contains an integer T denoting the number of test cases. The next T lines contains N values i.e. total number of matchsticks present on table.
For each test case, in a new line, print the number of match sticks A should pick for a guaranteed win. If it is not possible for A to win, print -1.
1 <= T <= 100
1 <= N <= 1019
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.