Matchsticks game
##### Submissions: 2451   Accuracy: 52.86%   Difficulty: Medium   Marks: 4

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.

Input:
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.

Output:
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.

Constraints:
1 <= T <= 100
1 <= N <= 1019

Example:
Input :
3
48
71
15
Output :
3
1
-1

#### ** For More Input/Output Examples Use 'Expected Output' option **

Author: Somya_Goel

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.