The Voight-Kampff test

0.64

Blade Runner Rick Deckard is identifying replicants at Tyrell Corporation. Rick distinguishes who is a replicant and who is human using a Voight-Kampff machine, which is a sort of lie detector that measures contractions of the iris muscle and also the degree of the empathic response of individuals through careful questions.

How complicated… Rick is so tired of it! Therefore, he will just pretend that he is making the Voight-Kampff test, while in fact he will only record some answers. Rick makes these assumptions: all humans and replicants know who is what (because humans at Tyrell Corporation are genetic designers, and replicants are smarter than Rick), humans always tell the truth, and replicants always lie.

0.36

For instance, consider the first example of the sample input, where Tyrell claims that Rachael is a replicant, and Rachael claims that Tyrell is a replicant. Under Rick’s assumptions, there are exactly two situations consistent with these two claims: (1) Tyrell is human and Rachael is a replicant, and (2) Tyrell is a replicant and Rachael is human.

Input

Input consists of several cases. Every case begins with a number 2n10002 \le n \le 1000, followed by nn different names, and by a number m0m \ge 0. Follow mm lines, each with an answer following exactly the format of the sample input. No individual speaks about (him/her/it)-self.

Output

For every case, print its number starting at one, and the number of situations consistent with the answers recorded and Rick’s assumptions. This number will always be less than 2312^{31}.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:22:42.958Z

© Jutge.org, 2006–2026.
https://jutge.org