Animal Enclosures X20976


Statement
 

pdf   zip

html

There are a number of animals who are grouped in enclosures. Write a program that keeps track of which enclosure each animal belongs to. 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 M denoting the number of enclosures. The enclosures are given on the following lines on the format “<enclosure name> <K>, where K is the number of animals in the enclosure. Each enclosure is followed by K lines with the names of the animals.

Output

For each animal in the order they appear in the input, print the following line:
X is of the species Y
For each enclosure in the order they appear in the input, print the following line:
Enclosure Z contains animals AA, BB, CC, ...
All placeholders (X, Y, Z, 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
    2
    A 2
    Pikatxu
    Jumbo
    B 2
    Kermit
    Puss in Boots
    

    Output

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