You just got a new job as a Byzantine Ancestry Project Coordinator where you try to piece together ancient family trees of people long dead. Because you can no longer ask them any questions, you have to rely on documents left from that era where names are written patrilineally: ancestry is only traced by the name of someone's father. One example of such name would be "Basil, son of Alexios". You are trying to prove your research hypothesis: the entire Byzantine population is descended from just a single common ancestor.
In order to prove this hypothesis, you need to determine whether such a family tree exists: find one possible family tree with a single root. You cannot create imaginary people or construct familial relations for which there is no historical evidence. One father can have multiple children, but one child cannot have multiple fathers. It is possible that different people have the same name.
The input consists of:
If it is possible for the given people to have a single common ancestor, output "possible". Otherwise, output "impossible".
3Jacob, son of IsaacIsaac, son of AbrahamIshmael, son of Abraham
possible
2Basil, son of AlexiosProcopius, son of Constantine
impossible
3Alvin, son of BertBert, son of CharlesCharles, son of Alvin
possible
2James, son of HarryHarry, son of James
possible
3Albert, son of BrentCody, son of BrentBrent, son of Daniel
possible
3Aaron, son of AaronAaron, son of BobbyBobby, son of Chris
possible
3Chris, son of BobbyBobby, son of AaronAaron, son of Aaron
possible