It is celebration time at Jalpaiguri Govt Engg College (JGEC) as one of its students, Souvik,
has bagged a job at Google India, Hyderabad. But Google, being a big company has given
very less time to reach Hyderabad for reporting. There are no direct flights and only two
routes for reaching Hyderabad are either taking a flight to Kolkata or Delhi and then board a
connecting flight from Kolkata/ Delhi towards Hyderabad. The time consumed by flights are
as follows:-
Source Destination Flight duration
Siliguri Delhi 4 hrs
Siliguri Kolkata 2 hrs
Delhi Hyderabad 5 hrs
Kolkata Hyderabad 6 hrs
There are A flights for Siliguri-Delhi, B flights for Siliguri-Kolkata, C flights for Delhi-Hyderabad, D flights for Kolkata-Hyderabad.
Find if Souvik wins this elusive race to become JGEC’s first ever Googler.
Input Format
First line consists of single integer t denoting the number of test cases in the input.
Second line consists of an integer N denoting the reporting time in 24 hour format at Hyderabad.
Third line consists of four integers A, B, C, D denoting number of flights in each sector.
Next four lines consists of A integers, B integers, C integers and D integers respectively denoting the starting departure timings of the flights in 24 hour format.
Output Format
The output should consist of the string "HISTORY IS MADE!" (in capital without quotes) if Souvik is able to make it in time for reporting. Else the output should “BAD LUCK!” (in capital without quotes).
Input Constraints
1 ≤ T ≤ 10000
1 ≤ A, B, C, D ≤ 30
Note: Please consider the fact that Souvik cannot take a connecting flight at the exact time his flight lands on.
There are many flights in which Souvik can reach Hyderabad before 1900 hours. One example is he can take the 0000 flight from Siliguri to Delhi and reach at 0400 and then can take the connecting 0830 flight to Hyderabad to reach at 1330 which is well before the 1900 deadline.