The input consists of Z assignments. The number of them is given by the single positive integer Z appearing on the first line of input.
Each assignment begins with one empty line that separates it from the previous text. Then there is the single number P (1 <= P <= 10) stating the number of players. Then exactly P lines follow, each containg name of one player. The name consists of letters only, the first one is capital, all the others are lowercase. In the remaining input, the names are always given in the exactly same form as the first time. Every name has at least one and at most ten characters. No name can be "Lharu" or "Poctivcu".
Then there is a single number M (0 <= M <= 500) on the separate line. This is the number of formulas to follow. Then there are exactly M lines, each of them has the exact format: name of the player, colon, one space, the formula and period. No line can be longer than 1000 characters. The formula has one of the forms (X,Y,Z are non-negative integers; H,F are player names; V,W are formulas). Note that the formula of type 4 ends with a period, any other formula does not.
1. X + Y = Z
2. H je poctivec (H is Honest)
3. H je lhar (H is Liar)
4. H rika "V". (H says V)
5. H rika "V" a je to opravdu tak (H says V and it's really true)
6. H rika "V", ale neni to pravda (H says V but is lying)
7. Poctivcu je mene nez X (There are less than X Honests)
8. Poctivcu je vice nez X (There are more than X Honests)
9. Poctivcu je alespon X (There are ate least X Honests)
10.Lharu je mene nez X (There are less than X Liars)
11.Lharu je vice nez X (There are more than X Liars)
12.Lharu je alespon X (There are ate least X Liars)
13.(V) a zaroven (W) ((V) and (W))
14.(V) nebo (W) ((V) or (W))
The formula of type 4 is true if and only if the player H could say the formula V without breaking the rules (that means if V is not true and H is liar, or if V is true and H is honest). Formulas 5 a 6 consist of two independent formulas ("H says V" and "V is [not] true"). If the author of the formula is liar, both of these parts must be false. If he is honest, both parts must hold. The formula consisting of one true part and one false part is called non-satisfiable (@@@) and noone can say it without breaking the rules. The formulas 7 through 12 mean the total number of liars (or honests) so the author of the formula also counts. Formula 13 is true if the both parts are true, and false, if any of them is not true. The formula 14 is true if any of its parts is true. If any of the parts of the formula of type 13 or 14 is non-satisfiable, it is counted as if it was false. Even two non-satisfiable formulas connected with the and or or give false result (not non-satisfiable result). That means that liar can say such formula.