403229: GYM101086 A My Friend of Misery
Description
With the SCPC2015 getting closer, Noura Boubou, SCPC Head of Media, was very busy to the extent of not having time to recharge her phone's credit balance. However, her best friend, Nicole, was kind enough to transfer her own credit for the sake of keeping Noura online 24/7.
The phone credit transfer system in Syria works in the following way: Each successful transfer operation withdraws 25 extra credit units from the sender's balance, but it doesn't cost anything when a transfer operation is unsuccessful due to non sufficient credit balance.
Given the log of credit transfer requests and the response from the system to each request, in the form: Amount of transfer, and result of operation (either successful or unsuccessful), can you find out the number of possible initial credit balance values that Nicole could have had which satisfy the given log file?
Note that the initial credit balance is always a non negative integer.
InputThe first line of input contains an integer T (1 ≤ T ≤ 256), the number of test cases.
The first line of each test case contains an integer N (1 ≤ N ≤ 105), the number of operations in the log of credit transfer requests.
Each of the following N lines contains an integer mi (1 ≤ mi ≤ 106), the amount of credit to transfer, followed by .
- { + } denotes a successful operation.
- { - } denotes an unsuccessful operation.
Each log contains at least one unsuccessful operation.
OutputFor each test case, print a single line that contains the number of possible initial credit balance values that Nicole could have had.
ExamplesInput3Output
3
512 -
128 +
256 +
4
80 +
70 +
200 -
150 +
3
100 -
100 -
540 -
103Note
50
125
Warning: large Input/Output data, be careful with certain languages.