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.


-----Input-----

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.


-----Output-----

Print a single integer — the maximum sum of happiness that you can gain from watching all the fireworks.

Please, do not write the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.


-----Examples-----
Input
50 3 1
49 1 1
26 1 4
6 1 10

Output
-31

Input
10 2 1
1 1000 4
9 1000 4

Output
1992

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'from collections import deque\nn,m,v=map(int,input().split())\nx,t,b,bt,dp,mi,mi2,mi3,dpmin,dp2=[0]*300,[0]*300,0,0,[[0]*2for i in range(150001)],0,100000000000000,10000000000000,0,[0]*150001\nd=deque()\nfor i in range(m):\n    x[i],b,t[i]=map(int,input().split())\n    bt+=b\nfor i2 in range(m-1):\n    if i2==0:\n        for i in range(1,n+1):\n            dp[i][0]=abs(i-x[0])\n            if mi2>dp[i][0]:\n                mi2=dp[i][0]\n    if m==1:\n        break\n    if(t[i2+1]-t[i2])*v>=n:\n        mi3=mi2\n        mi2=1000000000000000000\n        for i in range(1,n+1):\n            dp[i][0]=mi3+abs(i-x[i2+1])\n            if mi2>dp[i][0]:\n                mi2=dp[i][0]\n        continue\n    mi2=1000000000000000000\n    for i in range(1,n+1+(t[i2+1]-t[i2])*v):\n        if i<=n:\n            while (len(d)>0 and dp[i][0]<=d[len(d)-1][0]):\n                d.pop()\n            dp[i][1]=i+2*(t[i2+1]-t[i2])*v+1\n            d.append(dp[i])\n        if d[0][1]==i:\n            d.popleft()\n        if i-(t[i2+1]-t[i2])*v>=1:\n            dp2[i-(t[i2+1]-t[i2])*v]=d[0][0]+abs(x[i2+1]-(i-(t[i2+1]-t[i2])*v))\n    for i in range(1,n+1):\n        dp[i][0]=dp2[i]\n        if dp2[i]<mi2:\n            mi2=dp2[i]\n    d.clear()\nfor i in range(1,n+1):\n    if i==1:\n        mi=dp[i][0]\n    if dp[i][0]<mi:\n        mi=dp[i][0]\nprint(bt-mi)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13297003