URI Online Judge | 2724

Help Patatatitu

By Felipe C. Ochial, URI BR Brazil

Timelimit: 1

Juvenal behaved exemplary this year, since he likes chemistry deeply and really want to earn an Alchemy kit. However, Juvenal asked to include some dangerous elements in his kit. As Santa could not deny the request ( how to say no to the world most well behaved children?) asked to poor elf Patatatitu to ensure that the present was safe.

Patatatitu knows a lot about chemistry, and knows every dangerous compound that can be made with the elements available on Juvenal’s kit. Thus, he decided to send a cd together with the gift, containing a program which asserts the safety of Juvenal’s experiments. Everyone agrees that the world’s most well behaved children would never do an experiment without first checking it’s safety as per Santa instructions. However Patatatitu knows nothing about programming and is after someone to help him. Can you help?

To elucidate, Patatatitu explains that a dangerous compound are formed from a mix of elements in theirs chemical formula respecting it’s order and proportions. In this kit it’s possible to add one element each time, in various quantities. Thus, to form chlorine trifluoride (ClF3), an extremely dangerous compound, you must add an atom of chlorine (Cl) and three of fluorine (F3), regardless of what was added before or after. ClF4 is not a dangerous compound since it’s a different proportion from ClF3. Similarly, if Mg2F is a dangerous compound, Mg2Fe is safe, since fluorine (F) is different from iron (Fe).

Input

The input consist of an integer (0 < < 10) which indicates the number of test cases. Each test case have an integer T (0 < < 51) which indicates the number of dangerous compounds possible, if th elements are included in the order and proportions shown. Follow T lines, each containing a string up to 50 characters representing a formula that generates a dangerous compound if the elements are added in that particular order and proportion. After, is given an integer (0 < < 51) that indicates the number of experiments Juvenal will do. Follow U lines each containing an string up to 50 characters representing the elements that Juvenal will use in the order and proportions as they are added.

Output

The output consist of U per test case, which must inform if Juvenal must abort it’s experiment or proceed with the U-th experiment of the test case. If Juvenal must abort print “Abortar”, else if it’s safe print “Prossiga”.Test cases must be separated by a blank line .

Input Sample Output Sample

3

3

KH2O

C3H5N3O9

ClF3

5

WOsFNeSeBrSnAsNOH4C12CuKZrBr

C8H10N4O2C2H7NO3SC6H5NO2

C3H5N3O9ClF3KH20

C3H5N3O9

4P12Si7CNF12BLiClF312ON12H

2

H20NaCl

C6H12F2

4

H20Na

C6H12F

H20NaCl

C6H12F2

3

KBrAsC

Mg2F

CsH

6

KBrAsCl

Mg2Fe

CsHe

Mg2F

Cl2NaOPMg2F

KBrAsC

Prossiga

Prossiga

Abortar

Abortar

Prossiga


Prossiga

Prossiga

Abortar

Abortar


Prossiga

Prossiga

Prossiga

Abortar

Abortar

Abortar