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.

EISTOCK4 - Inventory Management

The current warehouse management software of ABC Company requires an upgrade, and the new software should be able to manage import/export transactions based on the first-in, first-out rule. The priority should be given to the products that arrived first. If the output transaction exceeds the inventory count, it will not be processed. Given a list of transactions that need to be processed in order, the output should show the products in stock after executing the transactions. It should be noted that there are no products in the warehouse initially.

Input

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

-          The ith line in the next N lines begins with a +/- sign corresponding to an import/export transaction, followed by 4 integers Ci, Qi, Pi and Ti, respectively, the item code, quantity, and unit price of the product. per product, time of transaction (Qi, Pi, Ti <= 109, Ci with no more than 9 digits). The time of the following transaction is always greater than or equal to the previous transaction.

Output

For each product in stock, with every import transaction that the product has not been totally exported, output the product code, value of the remaining products based on the input price, and the time the product was imported.

Products are printed in ascending order of product code and imported time.

Sample

Input

Output

6

+ 1 25 20000 1

-  1 20 30000 2

+ 2 15 30000 2

-  2 25 25000 4

-  2 5 20000 5

+ 2 15 20000 5

 

1 100000 1

2 300000 2

2 300000 5 

 

Explanation:

-          Product 1: import 25 products, export 20 then there are 5 products left of the first import. Therefore, value of the remaining products should be 5 * 20000 = 100000

-          Product 2:

+ Import 15, cannot export 25, but export 5. There are 10 products left in stock of the first import, then value = 10 * 30000 = 300000

+ Import 15, no export, value = 15 * 20000 = 300000


Added by:Ha Minh Ngoc
Date:2023-04-02
Time limit:1s
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.