OFFSIDE - He is offside!

Hemisphere Network is the largest television network in Tumbolia, a small country located east of South America (or south of East America). The most popular sport in Tumbolia, unsurprisingly, is soccer; many games are broadcast every week in Tumbolia.

Hemisphere Network receives many requests to replay dubious plays; usually, these happen when a player is deemed to be offside by the referee. An attacking player is offside if he is nearer to his opponents’ goal line than the second last opponent. A player is not offside if

  • he is level with the second last opponent or

  • he is level with the last two opponents.

Through the use of computer graphics technology, Hemisphere Network can take an image of the field and determine the distances of the players to the defending team’s goal line, but they still need a program that, given these distances, decides whether a player is offside.

Input

The input file contains several test cases. The first line of each test case contains two integers A and D separated by a single space indicating, respectively, the number of attacking and defending players involved in the play (2 <= A,D <= 11). The next line contains A integers Bi separated by single spaces, indicating the distances of the attacking players to the goal line (1 <= Bi <= 104). The next line contains D integers Cj separated by single spaces, indicating the distances of the defending players to the goal line (1 <= Cj <= 104). The end of input is indicated by A = D = 0.

Output

For each test case in the input print a line containing a single character: “Y” (uppercase) if there is an attacking player offside, and “N” (uppercase) otherwise.

Example

Input:
2 3
500 700
700 500 500
2 2
200 400
200 1000
3 4
530 510 490
480 470 50 310
0 0

Output:
N
Y
N

Added by:Camilo Andrés Varela León
Date:2007-12-02
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:The 2007 ACM South American Programming Contest

hide comments
2015-07-02 07:39:11 Shantanu Banerjee
I guessed the first opponent is the Goalkeeper himself :P AC
2015-05-22 04:27:43 SangKuan
easy
2015-04-17 11:34:46 Prasanna Patil
I accidently swapped conditions of Y and N, costed me one WA :'(.
Otherwise Easiest one
2015-04-10 22:51:30 Satvik Maurya
The language is very confusing. Couldn't have done it without the comments.
2015-03-13 12:27:02 [Mayank Pratap]
My 50th...comments helped a lot to understand problem statement...implementation was easy...
2015-02-27 12:23:37 :.Mohib.:
Your comment Help..@Eelmaa
2015-02-17 15:33:15 Petar Kovacev
So, if at least two defenders are <= to goal than the attacker, the attacker is not offside? Never mind if their distance(those two defenders' distance) is the same (500,500) or different(400,500, for example)?
2015-02-06 07:52:27 Indian Cyber Army (IndiShell)
Solved with the help of comments....!
2015-01-24 13:57:30 Rahul
Easy one !!!
2015-01-18 16:27:31 Gohan
AC in first go.So easy !!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.