fight-in-indiahacks
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

IndiaHacks-2016 is going on and Tom and Jerry also came to participate in the contest. Tom and Jerry started fighting in the contest too, as always! As this is the INDIAHACKS Contest so 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.

We strongly recommend you to take part in the contest with Tom and Jerry so register yourself at IndiaHacks-2016

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


for _ in range(int(input())):
	n, m1, m2 = list(map(int, input().split()))
	x = n % (m1 + m2)
	if m1 == 0:
		print(1)
	elif x < m1: 
		print(0)
	elif x == m1 or x >= m2:
		print(1)
	else:
		x /= m1
		print(1 if x & 1 else 0)