13440 - Animal World   

Description

There are N animals consisting of cats, fish, birds, and humans in a beautiful world.

Each animal has an unique name.

Initially, the HP of each animal is 0.

 

You have to perform the following operations:

 

  • Name <i>:Print the name of the i-th animal.
  • Species <i>:Print the species of the i-th animal.
  • HP <i>:Print the HP of the i-th animal.
  • Talk <i>:If the i-th animal is
    • human, print "Hello, world".
    • bird, print "Suba".
    • fish, print "?".
    • cat, print "Meow".
  • Breath <i> <x> :Increase the HP of the i-th animal by x.
  • Sleep <i> <x>:If the HP of the i-th animal is less than or equal to 100, multiply its HP by x.
    • (Note that its HP may become larger than 100 after this operation)
  • Eat <i> <j>
    • If the i-th animal is cat and the j-th animal is fish,
    • or the i-th animal is bird and the j-th animal is fish,
    • or the i-th animal is human and the j-th animal is fish or bird,
      • then increase the HP of the i-th animal by the HP of the j-th animal
      • and turn the HP of the j-th animal into 0.
    • If the i-th animal is human and the j-th animal is cat,
      • then turn the HP of the i-th animal into 0.
    • Otherwise, do nothing. 

 

Input

The first line of the input contains a number N Q — the number of animals in the world and the number of operations.

Each of the next i = 1, 2, ..., N lines contains two strings — the species and the name of the i-th animal.

The next Q lines is one of the operations described in the statement.

 

N ≤ 1000

Q ≤ 300000

1 ≤ x ≤ 10 in operation Breath and Sleep

1 ≤ i, j ≤ N in every operation

 

Output

Whenever there's an operation "Name <i>", print the name of the i-th animal.

Whenever there's an operation "Species <i>", print the species of the i-th animal.

Whenever there's an operation "HP <i>", print the HP of the i-th animal.

Whenever there's an operation "Talk <i>", print the corresponding sentences according to the problem statement.

Remember to print '\n' at the end of each line.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13440.cpp

Partial Judge Header

13440.h

Tags




Discuss