402180: GYM100687 F Proficiency Test (B)

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Proficiency Test (B)time limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

A group of students took the profeciency test and were filtered as described in the previous question. Mr. Rabah was printing a document on Dr. Arafat’s machine and accidently deleted the questions from the database! No one now can tell which questions are the 6 simple questions.

The correct answers, the answers of the students and the decision for each student are all still available. However, we need to know the 6 simple questions in order to make decisions about the remaining groups of students.

Given the correct 48 answers, the answers of some students, and the decision of the program from the previous task for each student, can you save Rabah and identify for sure (uniquely) the 6 simple questions?

Input

The first line of the input contains the correct answers as a string of 48 letters. The second line contains an integer N (1 ≤ N ≤ 100) representing the number of students for whom the decisions were available before losing the questions.

Each of the next N lines contains a string of 48 letters, representing the answers of one of the students, followed by “-“ if this student’s records were removed or + if the records were not removed.

It is guaranteed that the given data is valid.

Output

Print “No” if it is impossible to identify the 6 questions uniquely, otherwise print “Yes”.

ExamplesInput
AACAADADCAADDDBCDABCDBBCACABCCCDADABCCCDCADADAAA
2
AACBDDADCAADDDBCDABCDDDCACABBCCDADABACCDCDDACABA +
AACDCDACCAADCABCBABCDDBCADABCBCDAAABCDCDCADABBAA -
Output
No
Input
AACAADADCAADDDBCDABCDBBCACABCCCDADABCCCDCADADAAA
2
DACAADADCAADCDBCDACCDBBCACABCCCDADABCCCDCADADAAA -
AACAADADCAADDDBCDABCDBBCACABCDCDADABCACDCADABAAA -
Output
Yes

加入题单

上一题 下一题 算法标签: