A festival will be held in a town's main street. There are *n* sections in the main street. The sections are numbered 1 through *n* from left to right. The distance between each adjacent sections is 1.

In the festival *m* fireworks will be launched. The *i*-th (1 ≤ *i* ≤ *m*) launching is on time *t*_{i} at section *a*_{i}. If you are at section *x* (1 ≤ *x* ≤ *n*) at the time of *i*-th launching, you'll gain happiness value *b*_{i} - |*a*_{i} - *x*| (note that the happiness value might be a negative value).

You can move up to *d* length units in a unit time interval, but it's prohibited to go out of the main street. Also you can be in an arbitrary section at initial time moment (time equals to 1), and want to maximize the sum of happiness that can be gained from watching fireworks. Find the maximum total happiness.

Note that two or more fireworks can be launched at the same time.

The first line contains three integers *n*, *m*, *d* (1 ≤ *n* ≤ 150000; 1 ≤ *m* ≤ 300; 1 ≤ *d* ≤ *n*).

Each of the next *m* lines contains integers *a*_{i}, *b*_{i}, *t*_{i} (1 ≤ *a*_{i} ≤ *n*; 1 ≤ *b*_{i} ≤ 10^{9}; 1 ≤ *t*_{i} ≤ 10^{9}). The *i*-th line contains description of the *i*-th launching.

It is guaranteed that the condition *t*_{i} ≤ *t*_{i + 1} (1 ≤ *i* < *m*) will be satisfied.

提交代码