A new town was just inaugurated in a small country. As usual, Mirko has secured the position of the chief tax inspector. His duty is ensuring adequate accounting in all the different companies in the town. There are
A company moving in is described by four integers:
– the move-in day, numbered from town inauguration (which is day ), – the office number, – the daily profit of the company (can be negative if the company is losing money), – balance of the company's account on move-in day.
If there is already a company in office
Mirko's inspection stroll is described by three integers:
– the inspection day, numbered from town inauguration, and – Mirko will pass by all offices with numbers between and , inclusive.
Since Mirko works only at the end of the day, all companies will have already finished business and posted profit for the day by the time of Mirko's stroll.
Help Mirko by writing a program to find, for each stroll, the account balance of the currently wealthiest company that Mirko is passing by.
Input Specification
The first line of input contains two positive integers,
Each of the following 1 T K Z S
(for company move-in) or as 2 T A B
(for Mirko's inspection stroll).
All events are given chronologically, and at most one event will happen each day (that is,
Output Specification
For each one of Mirko's strolls output a line containing the account balance of the company that Mirko will inspect, or the word nema
if all offices that he will pass by are empty.
Sample Input 1
2 4
1 1 1 2 4
1 2 2 3 2
2 5 1 2
2 7 1 2
Sample Output 1
12
17
Sample Input 2
3 6
1 1 1 4 -2
1 2 2 2 6
2 3 3 1
2 4 3 1
1 5 3 -6 20
2 6 2 3
Sample Output 2
8
10
14
Sample Input 3
5 9
1 1 5 4 -5
2 2 3 5
1 3 4 6 9
2 4 1 2
1 6 2 2 3
2 8 2 1
1 9 4 0 17
2 10 5 5
2 11 1 4
Sample Output 3
-1
nema
7
31
17
Comments