Martin and Isa are very competitive. The newest competition they have created is about looking at the plates of the cars. Each time one of them sees a car plate in the streets, he or she sends to the other an SMS message with the content of that plate; the one who has seen the newest plate is in the lead of the game. As the Automobile Car Management (ACM) office assigns the plates sequentially in increasing order, they can compare them and find out who is the winner.
Martin has a very smart eye and he has stayed on the lead for several weeks. Maybe he keeps looking at the streets instead of working, or maybe he stays all day in front of car selling companies waiting for new cars to go out with new plates. Isa, tired of being always behind, has written a program that generates a random plate, so the next time Martin sends a message to her, she will respond with this generated plate. In this way, she hopes to give Martin a hard time trying to beat her.
However, Martin has grown suspicious, and he wants to determine if Isa actually saw a car with the plate she sent or not. This way, he will know if Isa is in the lead of the game.
He knows some facts about the plates assigned by the ACM:
As Isa is not aware of all of this, she has just made sure that her random generator creates a combination consisting of seven characters, where the first three characters are always uppercase letters, the last two characters are always digits, and each one of the fourth and fifth characters may be an uppercase letter or a digit (possibly generating an illegal combination, but she has not much time to worry about that).
Of course, Martin will not consider Isa the winner if he receives an illegal combination, or if he receives a legal plate, but equal to or older than his. But that's not all of it. Since Martin knows that new plates are not generated too fast, he will not believe that Isa saw a car with a plate newer than the one he sent, but sequentially too far. For example, if Martin sends DDDDD45, and receives ZZZZZ45, he will not believe that Isa saw a car with that plate, because he knows that the ACM couldn't have printed enough plates to get to ZZZZZ45 in the time he received that answer.
So, Martin has decided to consider Isa the winner only if he receives a legal plate, newer than his, and older than or equal to the C
The input contains several test cases. Each test case is described in a single line that contains two strings SM
$(1 \le C \le 10{9})$
-->
(1
WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/0831-1.png"
ALT="$ \le$">C
WIDTH="18" HEIGHT="31" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/0831-1.png"
ALT="$ \le$">109)
The end of input is indicated by <!-- MATH
$S_{M} = S_{I} =$
-->
SM = SI =
For each test case, output a single line with the uppercase character <TT>Y</TT>" if, according to Martin, Isa is the winner, and with the uppercase character
N" otherwise.
ABC1234 ABC1240 6
ABC1234 ABC1234 6
ACM5932 ADM5933 260000
BBBBB23 BBBBC23 100
BBBBB23 BBBBD00 77
ZZZ9997 ZZZ9999 1
ZZZ9998 BBBBB01 3
ZZZZZ95 ZZZZZ99 10
BBBBB23 BBBBB22 5
* * 0
Y
N
N
N
Y
N
Y
Y
N
Migrated from old NTUJ.
South America 2007
No. | Testdata Range | Score |
---|