Limits
1s, 512 MB

Today I’m going to flash a lift trick. We have 5 lifts for students. One is local(!)(Every UAPians know about that lift) other 4 lifts are regular lifts. Among these lifts lets consider west sided 2 lifts. Between these 2 lifts, only lift2(right sided) stops at (1,3,5,7,9) floors and lift1(left sided) stops at (1,2,4,6,8,9) floors. Our department is on 7th floor so only lift2 stops on our floor. But not anymore, from now we’ll force lift1 to stop on our floor! Suppose you are at 1st floor on lift1 you need to press button 8. When you are crossing 6th floor press 8 immediately to cancel the call. It’ll stop on 7th floor! But one problem, if someone is on 8th/9th floor and call for lift, this trick **won’t work**. But it will work if someone calls from less than 7th floor. Trick also works when you need to go down.

Now little Emma is on Floor C (1 ≤ C ≤ 9) and Lift L (1 ≤ L ≤ 2). 1 means lift1 and 2 means lift2. Initially lift’s gate is open. She needs to go to Xth(1 ≤ X ≤ 9) floor. You must help Emma so that she can reach Xth floor. So you pressed a button to reach Xth floor(may not always button X because you know the trick). Life is just like math, when it goes too easily you should be concerned that something is definitely wrong!! After you entered into the lift, you got a message from your hacker friend Groot. He has given you the list of floors which are currently called (they all called the lift at the same time, you can assume that it happened after you pressed the button) the lift. You know a great(!) trick but can you reach to her desire floor without changing the lift’s direction?

The first line of the input contains a single integer t(1 ≤ t ≤ 10000), denoting the number of test cases.

First line of each test case contains three space separated integers

C(1 ≤ C ≤ 9) Emma’s current floor, L(1 ≤ L ≤ 2) current lift, and X(1 ≤ X ≤ 9) the floor she wants to reach.

Next line contain two integers N(0 ≤ N ≤ 10), M(0 ≤ M ≤ 10) number of people calling for lift1 and lift2 respectively.

Next line contains N integers Ni ∈ {1,2,4,6,8,9} Ni indicating the calls for lift1.

Then Next line contains M integers Mi ∈ {1,3,5,7,9} Mi indicating the calls for lift2.

Assume that, initially lift’s gate is open.

For each test case if it’s possible to reach Emma’s desire floor print “Happy Emma!” (without quotes), print “Dhat! Shobshomoy amar shathei ken emon hoy!”(without quotes) otherwise.

Input | Output |
---|---|

2 1 1 7 2 2 4 2 1 5 2 2 8 3 2 2 4 6 5 9 | Happy Emma! Dhat! Shobshomoy amar shathei ken emon hoy! |

First case is explained in the description, you can use the trick to stop at 7th floor.

For second case you are at lift2 but you need reach 8th floor, someone already called 9th floor so you can not stop at 8th floor.

Note: you can only enter Lth lift, it means somehow you are at Cth floor and only Lth lift’s door is open.

Toph uses cookies. By continuing you agree to our Cookie Policy.