HZNUOJ

Webgame GuduSanGuo

Tags:
Time Limit:  10 s      Memory Limit:   64 MB
Submission:0     AC:0     Score:100.00

Description

Webgame is a new style of game; you do not need the game client. Users can play through the browser. GuduSanGuo is a strategy type of webgame, in GuduSanGuo you can build your own army to attack other country.

There are many kinds of units you can build. Each unit has its own attributes: attack, hit point (hp), armor. When you own a strong army, you can start the war. Of course before the war, you must detect the military strength you attack against. For a coming war, you have to estimate the cost of the war. In the game the cost of the war is the units you lost which can calculated as follows: the number of lost units = (attacks - armor) / hp. Each war breakout among cities, in a city there are more than one kind of unit. So the damage should distribute to each unit. The damage each unit bear is decided by the number of units in the proportion of total units count. For example, there are two kinds of unit: Footman and Archer. The number of Footman is 70 and Archer is 30.If the total damages is 100,the result is,70% damages to Footman and 30% damages to Archer.

Science and technology played an important role, you can upgrade your army’s defense and attack, and you can assume that each level upgrade 10% of the unit’s initial armor and attack.

Also you can attack one city with many cities simultaneously, but the war is calculated separately and the order of the war is decision by arrive time. Now can you program and calculate the results of the war? You should note that all calculations are based on integer, the decimal is ignored.

Input

First line of input is a integer m(m<10) means the number of units. Then followed by m lines, each line contains the unit name, attack value, armor and hp. The next is the information of the city you attack include city name, technology level, and Military details, first line is city name, next line is technology level, then a integer t means the number of units the city have. Followed by t lines contain each unit's name and the number of unit. You can assume that all the unit names are occurred in the total units before. The last is your cities' information. The beginning is the number of cities n(n<10). Then n blocks of city information follow. The format is the same as before, but each block contain an arriving time (an integer) at last.

Output

You should output all war's result, for each war you should give the Attacking side's and Defensive side's basic information such as city name, each unit's name and the number, total attacks and armors then you have to output the lost unit. The sequence of units is ordered by unit name and the war's sequence is ordered by arriving time, that means which war begin first output first. You can see the simple output for the detail.

Samples

input
8 Swordman 18 10 100 LongPikeman 60 25 150 Archer 70 20 120 Lancesoldiers 45 30 160 LightCavalry 70 25 160 RePikeman 80 50 180 EvenCrossbowmen 145 20 260 Hussars 200 45 465 changsha 0 1 Swordman 100 2 yongzhou 0 2 Swordman 70 Archer 30 30 xian 0 2 Swordman 70 Archer 30 40
output
Attacking side: CityName:yongzhou Unit: Archer 30 Swordman 70 Total Attacks:3360 Total Armors :1300 Lost Unit: Archer 1 Swordman 3 Defensive side: CityName:changsha Unit: Swordman 100 Total Attacks:1800 Total Armors :1000 Lost Unit: Swordman 23 Attacking side: CityName:xian Unit: Archer 30 Swordman 70 Total Attacks:3360 Total Armors :1300 Lost Unit: Archer 0 Swordman 0 Defensive side: CityName:changsha Unit: Swordman 77 Total Attacks:1386 Total Armors :770 Lost Unit: Swordman 25

Source

3rd Central South China Programming Contest