We all know the concept of food chain in nature, and there is a similar situation in NTHU - The counter cycle among elephants, cats, and bugs (don’t worry, elephants won’t eat cats). These three species engage in battles on campus, the rules are as follows.
The counter relationship:
Once a contestant is dead (HP = 0), it cannot attack, heal, or revive anymore (but you still have to output the result of battle).
All attacks will not deal negative damage, and the minimum HP is 0.
There are n
contestants and q
battles. Please output the remaining HP of the defender after each battle.
This is a partial judge problem. You only need to implement battle() function.
The illustrations below is the demostration of the sample case.
The first line contains two integers, n
and q
.
2 ≤ n
, q
≤ 1000
The following n lines each line contain a string and three integers s
, hp
, atk
and def
, representing the species, health point, attack power and defend power of i-th (1-based) contestant, respectively.
s
belong to {"Elephant", "Cat", "Bug"}
1 ≤ hp
≤ 1000
1 ≤ atk
, def
≤ 300
The following q lines each line contain two distinct integers a
and b
, representing the index of the attcker and the defender.
1 ≤ a
, b
≤ n
Output the remain HP of the defender, followed by a new line character '\n'
;