Dont Disturb Me !!!!!!!!!!

0

0 votes
Medium
Problem

Jack is an 8 year old kid. He has a battery operated toy train with all the tracks and platforms. He is a very keen genius. He builds different islands each having a separate railway network such that any platform can be visited from any of the platforms present in an island.

But he has a problem. He has a 3 year old sister named, Jolly, who is very very Naughty.As being a kid of this age , she wants to disturb her elder brother Jack. She sits on any of the platforms and takes out the railway tracks connected to it.

Jack is afraid that when her sister sits on any of the platform and takes out the tracks connected to it, his small battery train have to stop its journey if it wants to visit all the other platforms present in that island. So before running his train he wants to check if this situation can happen.

So he dictates the railway connectivity network to you ( his older brother) for checking.But, now also , as before, the little sister Jolly wants to disturb you two. She screams unwanted and meaningless words whenever Jack starts dictating the connectivity map to you.

INPUT

The first line of input contains two space separated integers N and M, where N is the number of platforms and M is the number of railway tracks.

Next M lines contain strings,each having two integer numbers(Ai and Bi) hidden in them representing a connection between the railway platform Ai and Bi.

Next input line contains an integer Q representing the number of queries.

Next Q lines contains an integer Yi representing a platform number

Output

For each query i, print "Happy Jack" (without quotes) , if Jolly disturbs the platform Yi in the manner mentioned above yet all the other platforms in that island can be visited without stopping the train's journey .

Otherwise, print "Sad Jack" (without quotes).

Constraints

1N,M105

1Ai,BiN

1QN

1YiN

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For the 1st query

Destroying the platform number 1, will not effect connectivity as the train can reach all the other platforms (2,3,4,5) from any of the platform(2,3,4,5).

For the 2nd query

If the platform number 2 is destroyed , then platform 3 can not be reached from platform 1.

Editor Image

?