Hide

Problem G
Job Qualifications

Accepted submissions to this problem will be granted a score of 100

Sending in job applications is not the most exciting task. One important thing to determine is whether one is qualified based on the requirements the company lists. In order to make this whole process easier on yourself, you should write a program to take care of this.

Obviously, companies only list true requirements, meaning that if you satisfy their requirements you should apply. However, if you do not satisfy them, then it is best not to bother. Would it not be silly to list a requirement that is not really required?

Input

The first line of input contains two non-negative integers $n$ and $m$, where $n$ is the number of qualifications you have and $m$ is the number of job listings. Then $n$ lines follow, each containing a string describing one of your qualifications. Finally, $m$ job listings will follow.

Each job listing starts with a line containing a non-negative integer $k$, the number of qualifications required for the job. Then $k$ lines follow, each containing a string describing one of the required qualifications.

Since humans can make mistakes when writing up lists, the same qualification may be listed multiple times in each job listing or in your list of qualifications.

Each qualification is a string of lowercase English letters with length between $1$ and $10$ inclusive. In large inputs, the length of each qualification is at most $5$ letters.

The total number of qualifications in the input is at most $1\, 000\, 000$.

Output

Output consists of $m$ lines, each describing which action to take for a job listing, containing either apply or why bother?.

Sample Input 1 Sample Output 1
9 2
fiveyears
degree
english
icelandic
javascript
frontend
html
css
sql
5
css
english
html
javascript
frontend
3
icelandic
sql
datastore
apply
why bother?
Sample Input 2 Sample Output 2
5 5
a
b
c
d
e
0
1
a
2
b
c
3
d
e
f
5
d
e
c
a
b
apply
apply
apply
why bother?
apply
Sample Input 3 Sample Output 3
0 2
1
baremin
0
why bother?
apply

Please log in to submit a solution to this problem

Log in