Sickly Yeongjeong

Map each symptom to its medicine name, then for every query list output the matching medicines in order or YOU DIED if any symptom is untreatable.

Easy3Hash mapImplementationArraySimulationInterviewNo attempts yetTime limit1sMemory limit512 MB

Problem

Yeongjeong is sickly. He knows it, so he keeps a stock of medicine with him and can take it at any time. Every medicine is labeled with its name and with the one symptom it treats, and a single medicine treats exactly one symptom. No two medicines share a name, and no two medicines treat the same symptom.

Given the symptoms Yeongjeong complains about, print the medicine he has to take.

Input

The program reads from standard input.

The first line holds the number of kinds of medicine NN. (1N1001 \le N \le 100)

Each of the next NN lines holds the symptom the medicine treats MeM_e and the name of the medicine MnM_n, both as numbers. (0Me,Mn1000 \le M_e, M_n \le 100) No two medicines share a name, and no two medicines treat the same symptom.

The next line holds the number of symptom lists RR. (1R1001 \le R \le 100)

Each of the next RR lines holds a count LiL_i followed by the symptoms S1,S2,,SLiS_1, S_2, \dots, S_{L_i}. (1LiN1 \le L_i \le N, 0Sj1000 \le S_j \le 100) The symptoms on one line are distinct.

Output

The program writes to standard output.

For each of the RR symptom lists, print one line with the names of the medicines to take, separated by spaces, in the order the symptoms were given.

If at least one symptom on a line cannot be treated, print YOU DIED on that line instead.