#000080

let

In front of you there is a screen divided into k vertical strips that are marked by the numbers 1, 2, ..., k from left to right. In the bottom of the screen there is an aircraft that can fly through the strips (from one strip only to the next strip). It needs 1 second to move to the next strip of the screen. N diamonds are falling from the upper part of the screen. There is a known price [] for every diamond, a strip l into which it falls (a certain diamond falls into this exact strip) and the known moment t when it touches the bottom of the screen. The aircraft is as wide as a strip and can take the diamond only when it has its entire width in the strip where the diamond is falling and when it is there at the exact moment when the diamond touches the bottom of the screen. If the aircraft begins to cross to another strip at the moment x, it will then find itself with its entire width in the neighboring strip at the moment x+1. So, if the aircraft begins to cross at the moment x into the neighboring strip s1 (s1 is s-1 or s+1), then it will pick up the diamonds in the strip s that are there at the moment x and the s1 diamonds that at the moment x+1 touch the bottom of the screen. While the entire width of the aircraft is in one strip, it can remain there indefinitely.


The aircraft can pick up the diamonds for t seconds. At the moment 0 the aircraft is in strip 1. Your task is to find the maximum price of the diamonds that the aircraft can pick up during the given period of time.


InputThe first line of the standard input contains the numbers k (1<k<50), n (1<n<100000) and t (1<T<100000). Data about the diamonds are in the next n lines. In i+1 line are the numbers ci (1<ci<1000000), li (1<li<k) and ti (1<ti<200000), which are the price of the diamond, the strip in which the diamond falls, and the moment in which the diamond will touch the bottom of the screen.

Output In the first line of the standard output write the maximum price of the diamonds that the aircraft can pick up.

Input:
[c]5 11 10
10 1 2
10 1 2
200 3 2
50 3 2
50 3 2
10 4 2
10 4 2
200 5 5
50 1 4
10 2 2
10 2 2

Output:
500


Input:
4 9 10
200 4 1
200 4 3
5 1 1
5 1 2
5 1 3
5 1 3
5 1 4
5 1 5
5 1 11

Output:
200
Explanation:
At the begining of the game the aircraft begins moving towards strip 4. It arrives at strip 4 in the 3rd second and picks up diamond that come to a total price of 200. After that there isn't any time for picking up (notice that the game ends after 10 seconds, so the diamond that will reach the bottom of the screen in the 11th second cannot be picked up).

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.