It's raining apples! At certain points in time, some number of apples will hit the number line. At certain points in time, some of Farmer John's cows will arrive on the number line and start catching apples.
If an apple hits the number line without a cow to catch it, it is lost forever. If a cow and an apple arrive at the same time, the cow catches it. Each cow can travel one unit per second. Once a cow catches a single apple, she exits the number line.
If FJ's cows collaborate optimally, how many apples can they catch in total?
The first line contains N (1≤N≤2⋅105), the number of times apples hit the number line or FJ's cows appear.
The next N lines each contain four integers q_i, t_i, x_i, and n_i (q_i∈1,2,0≤t_i≤109,0≤x_i≤109,1≤n_i≤103).
It is guaranteed that all of the ordered pairs (t_i,x_i) are distinct.
The maximum number of apples FJ's cows may collectively catch.