Tom and Jerry started fighting, as always! But this time the fight is on numbers. They ended up bringing a game to decide who is better. They have N marbles and they choose two integers M1 and M2, in each turn a player can take either M1 or M2 marbles(if available!). One who can't make any move further, loses.
Game is started with Jerry's turn always. Given N, M1 and M2, and assuming that both are playing optimally, tell us whether Jerry will win or not.
Input:
T, number of test cases then T lines containing three integers N, m1 and m2
Output:
1 If Jerry wins, 0 if Tom wins.
Constraints:
0<T<100
0< m1 <= m2, N <=1000000. Note that m1 or m2 can be greater than N.
Test files will be such that T*N < 10000000 .