"Long" and "Circuit" love each other but "Div" is jealous of both thus to break their relationship, he conducted a test for them. "Div" prepares a N*M Matrix (let us called that matrix as A) with each element A[i][j] between 1 and 1e9 (boundary included) and asks them 1<=Q<=1000 queries. Each query is made up of 8 integers such that first four integers are co-ordinates of first rectangular box and next four integers are co-ordinates of second rectangular box i.e. a,b,c,d,e,f,g,h are 8 integers.
NOTE:- (a,b) is upper leftmost and (c,d) is lower rightmost co-ordinates of first rectangular box i.e. rectangular box includes all elements of matrix whose top leftmost element is at [a][b] index and bottom rightmost element is at [c][d] index. Similarly , (e,f) and (g,h) are upper leftmost and lower rightmost co-ordinates of second rectangular box i.e. rectangular box includes all elements of matrix whose top leftmost element is at [e][f] index and bottom rightmost element is at [g][h] index.
After ignoring elements present in common intersected area of rectangle 1 and rectangle 2 ,if gcd(Greatest Common Divisor) of max and min of rectangular box 1 is G1 and gcd of max and min of rectangular box 2 is G2 then if G1>G2 , print "LONG WINS" ,if G1 < G2 then print "CIRCUIT WINS" else print "BOTH WINS".
Print all without quotes. Consider initially G1=G2=1 and gcd is to be calculated after removing elements in common area.
INPUT:-
The first line contains N and M and next N lines contains M space separated integers. And next line contains Q, the number of queries and next Q lines contains 8 space separated integers.
OUTPUT:-
Output the required answer for each query. 1e9 means 10 raised to power 9.
CONSTRAINTS:-
1<=N,M<=1000
0<=a,b,c,d,e,f,g,h<1000
For the query 1 of sample test, after ignoring the common element that i.e. area common both to rectangle 1 and rectangle 2 is starting at [1][1] and ending at [1][1] thus, we have to ignore this element i.e. 6. After ignoring this element, min of rectangle 1 is 1 and max is 12 i.e. G1=1 and G2=1(Because after ignoring common element, nothing is left in rectangle 2, hence G2 which was initially 1 remains 1). Therefore both win.