Олимпиадный тренинг

Задача 38333. Phone numbers


Phone numbers in the mobile phone's address book have one of the following formats:

+7<code><number>

8<code><number>

<number>

where <number> — is seven digits, and <code> — it's three digits or three digits in parentheses. If the code is not specified, then it is considered to be 495. In addition, the telephone number entry may contain the “-” between any two digits (see example).

At the moment, Vasya has only three phone numbers in his address book, and he wants to add another one there. But he cannot understand if such a number is already recorded in the phone book. Help him!

Two phone numbers match if they have the same codes and the same numbers. For example, +7(916)0123456 and 89160123456 — it's the same number.

Input
The first line of the input contains the phone number that Vasya wants to add to his phone's address book. The next three lines contain three phone numbers that are already in the address book of Vasya's phone.

It is guaranteed that each of the entries corresponds to one of the three formats given in the condition.

Imprint
For each phone number in the address book print YES (in capital letters) if it matches the phone number Vasya wants to add to the address book or NO (in capital letters) otherwise.
 
Examples
# Input Output
1 8(495)430-23-97
+7-4-9-5-43-023-97
4-3-0-2-3-9-7
8-495-430
YES
YES
NO