Under construction

Still being built. Things may change

Bryak

Interview

Time limit2sMemory limit1024 MB

Summary
Given containers with volumes and concentrations and a list of pours between them, find the final volume and concentration of each container.
Level

Easy3 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Statement

Эй, Брейн, чем мы будем заниматься сегодня вечером?

Тем же, чем и всегда, Пинки... Попробуем завоевать мир!

Пинки и Брейн.

Two extremely clever mice escaped from their cage in a very secret laboratory and decided to take over the world. To do so, they broke into the storage room, where several containers held a solution of a top-secret substance. The containers differed in volume and concentration.

To get a solution of the concentration they needed, the mice poured some liquid from one container into another. Just as they obtained the desired solution, guards arrived and the mice had to flee.

The surveillance cameras recorded everything that happened in the storage room. The scientists who work in this laboratory want to know what the mice were trying to do, so they will use the recording of the mice's actions to determine the concentration of the solution in each container.

Input

The first line contains an integer nn, the number of containers in the storage room (2≤n≤1002 \le n \le 100). Each of the next nn lines contains two integers viv_i and cic_i separated by a space, where viv_i is the volume of liquid in the ii-th container in liters and cic_i is its concentration in percent (0≤vi≤1090 \le v_i \le 10^9, 0≤ci≤1000 \le c_i \le 100). An empty container has a concentration of zero.

The next line contains an integer mm, the number of operations the mice performed (1≤m≤1001 \le m \le 100). Each of the next mm lines contains three integers aa, bb, and kk (1≤a,b≤n1 \le a, b \le n, a≠ba \ne b, 1≤k≤1091 \le k \le 10^9). This means that kk liters were poured from container aa into container bb. It is guaranteed that container aa holds at least kk liters of liquid at that moment. All containers are large enough to hold any volume of liquid.

Output

After all the pours, print the volume and concentration of the solution in each container, in the same format as the input. The concentration of each liquid must differ from the correct value by no more than 10−410^{-4} percent.

Examples1

  1. Example 1

    Input
    2
    10 50
    10 100
    1
    1 2 10
    
    Expected output
    2
    0 0.0000
    20 75.0000