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 .

Register for IndiaHacksSAMPLE INPUT
6
1 1 2
3 4 5
2 1 2
3 1 2
4 2 5
4 1 2

SAMPLE OUTPUT
1
0
1
0
0
1

Register for IndiaHacks
t = input()
while(t>0) :
    t -= 1
    n, m1, m2 = map(int, raw_input().split())
    rem = (n%(m1+m2))
    if (rem < m1) :
        print 0
    elif ((rem == m1)or(rem >= m2)) :
        print 1
    else :
        rem /= m1
        if (rem&1) :
            print 1
        else :
            print 0