Animal Friends

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 NN denoting the number of animals. The next NN 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 KK denoting the number of pairs of animals who are friends with each other. The next KK 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).

Problem information

Author: Anders Jonsson

Generation: 2026-01-25T15:06:35.531Z

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