Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

EISTOCK - Stock Management

 

Your sales department needs software to manage inventory and handle I / O transactions as well as statistics of total I / O values.
Note: Transactions are conducted in order. Shipments are rejected if there is not enough quantity to ship and initially there is no inventory.

Your sales department needs software to manage inventory and handle I / O transactions as well as statistics of total I / O values.

Note: Transactions are conducted in order. Shipments are rejected if there is not enough quantity to ship and initially there is no inventory

Input

The first line contains the number of transactions N(N <= 106).

ith line in the next N lines starts with '+' or '-' coresponding to import or export transaction, followed by 3 integers Ci, Qi and Pi which are Product's code, quanity and price for each item (Qi, Pi <= 109, Ci contains no more than 9 digits).

Output

At the end of the transactions, for each item that has at least one successful transaction, output the product code, the total value of the import goods, and the total value of goods shipped per line (separated by spaces).

Products are exported in ascending order of product's code

Example

Input:
6
+ 1 20 20000
- 1 20 30000
+ 2 15 30000
+ 3 20 25000
- 2 25 25000
- 3 5 20000

Output:
1 400000 600000
2 450000 0
3 500000 100000


Added by:Ha Minh Ngoc
Date:2017-08-23
Time limit:1s-1.200s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.