Coffee Cup

You have an ancient coffee cup excavated from the "COBOOOL remains", boiled water, and ground coffee. Let's brew a cup of coffee from those with an appropriate concentration.

You have three kinds of operations to brew coffee.

1.Pour "A" grams of boiled water to the cup. 2.Add "B" grams of ground coffee to the cup and stir. 3.For tasting, drink "C" grams of content in the cup.

When you have A grams of boiled water and B grams of ground coffee, after the each operation, the amounts of boiled water and ground coffee in the cup varies as follows:

Operation 1
《Pouring boiled water》
Operation 2
《Adding ground coffee》
Operation 3
《Tasting》
Boiled water X+A X X-C*X/(X+Y)
Ground coffee Y Y+B Y-C*Y/(X+Y)

You are given the operations. Find the concentration of the coffee after the all operations. Truncate a fractional part of the value. Note: For X grams of boiled water and Y grams of ground coffee, you can calculate the concentration (percentage) of the coffee as: 100*Y/(X+Y)

The following figure shows the content of the cup at example 2.



In this example, as the cup hold about 62.9 gram of boiled water and about 47.1 grams of ground coffee. So, the answer is 42 .
ミッション1

Find the concentration of the coffee after the all operations

Input

Input is given in the following format:
N
t_1 s_1
t_2 s_2
...
t_N s_N
The first line contains the number of operations "N". Each of the next "N" lines contains a kind of operation and amounts for the operation. For example:

If "t_i" is 1, i-th operation is "Pouring 's_i' grams of boiled water".
If "t_i" is 2, i-th operation is "Adding 's_i' grams of ground coffee".
If "t_i" is 3, i-th operation is "Drinking 's_i' grams of content of the cup".

Constraints

All test cases have the following constraints:
1 ≦ N ≦ 10
t_i is 1, 2, or 3
1 ≦ s_i ≦ 100
After the operation, the content of the cup is not empty.


Output

Output the concentration (percentage) of the coffee in the cup after all the operations, truncating a fractional part.
Add a newline character at the end of the output. Do not include any unnecessary characters or empty lines.
Input example 1
2
1 90
2 10


Output example 1
10
Input example 2
4
1 50
2 55
3 15
1 20
Output example 2
42

Answer

Please enter and submit the code that solves the problem above using the text box below.
You can use the following languages: Java, PHP, Ruby, Perl, Python, C, C#, and C++.

To find out about methods for reading values from standard input, please refer to the sample codes shown in the pages below:

Let's take the challenge!!Choose your best programming language and write some code!

Select language

Select your best programming language!

Code execution result

Nickname (Required)
You can use letters and numbers. This nickname may be displayed on our site when we publish your codes as sample solutions, or when we announce the prize winners.
email (Required)
Your registered e-mail address will not be used outside of Paiza Online Hackathon.
Once you submit your code, we will e-mail your results page.

ページの先頭へ戻る