Animal Friends X31418


Statement
 

pdf   zip

html

There are a number of animals who are friends with each other. Help them keep track of who is friends with who. Each animal has a name and a species among the four types “elephant”, “frog”, “cat”, or undefined.

Input

The input starts with an integer N denoting the number of animals. The next N lines are on the format “<animal type> <animal name>”, where <animal type> is the type of the animal (Elephant, Frog, Cat or Animal) and <animal name> is the name of the animal.
The next line has an integer K denoting the number of pairs of animals who are friends with each other. The next K lines are on the format “<name 1>–<name 2>”, where <name 1> and <name 2> are the names of the two animals who are friends.

Output

For each animal in the order they appear in the input, print two lines:
X is of the species Y
X is friends with AA, BB, CC, ...
All placeholders (X, Y, AA, BB, CC) should be replaced with the appropriate name or species (see the sample output for an example).

Public test cases
  • Input

    4
    Animal Pikatxu
    Elephant Jumbo
    Frog Kermit
    Cat Puss in Boots
    3
    Pikatxu-Jumbo
    Pikatxu-Kermit
    Kermit-Puss in Boots
    

    Output

    Pikatxu is of the species ...undefined...
    Pikatxu is friends with Jumbo, Kermit
    Jumbo is of the species elephant
    Jumbo is friends with Pikatxu
    Kermit is of the species frog
    Kermit is friends with Pikatxu, Puss in Boots
    Puss in Boots is of the species cat
    Puss in Boots is friends with Kermit
    
  • Information
    Author
    Anders Jonsson
    Language
    English
    Official solutions
    C++
    User solutions
    C++