output_description: Print the maximum possible score of a string.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      l_1 r_1 a_1
      l_2 r_2 a_2
      :
      l_M r_M a_M
attempt: # Starry Sky tree
  seg_el = 1 << 18  # Segment treeの台の要素数
  
  SEG = [0] * (2 * seg_el - 1)  # Segment tree.色々考えると0で初期化してOKそう
  ADD = [0] * (2 * seg_el - 1)  # 加算用Segment tree,SEG[k]+ADD[k]がkにおける本当の最大値
  seg_el_list = [
      524286,
      262142,
      131070,
      65534,
      32766,
      16382,
      8190,
      4094,
      2046,
      1022,
      510,
      254,
      126,
      62,
      30,
      14,
      6,
      2,
      0,
  ]
  
  
  def update(k):  # SEGのkより上のノードを更新（反映）
      while k >= 0:
          k = (k - 1) // 2
          if SEG[k] == max(
              SEG[k * 2 + 1] + ADD[k * 2 + 1], SEG[k * 2 + 2] + ADD[k * 2 + 2]
          ):
              break
          SEG[k] = max(SEG[k * 2 + 1] + ADD[k * 2 + 1], SEG[k * 2 + 2] + ADD[k * 2 + 2])
  
  
  def to_seg(a):  # aが終点となる区間をSegment treeの座標へ変換
      b = (a & (-a)).bit_length()
      return seg_el_list[b] + a // (1 << (b - 1))
  
  
  def add(a, b, x):  # 区間(a,b]にxを加算
      # print(a,b,x)
      while b != 0:
          ADD[to_seg(b)] += x
          update(to_seg(b))
          b -= b & (-b)
  
      while a != 0:
          ADD[to_seg(a)] += -x
          update(to_seg(a))
          a -= a & (-a)
  
  
  for i in range(N + 2):
      for b, k in end[i]:
          add(b, i, k)  # 点数がもらえる区間から出たときにその分を加算
  
      SEG[i + seg_el - 1] = SEG[0]
      update(i + seg_el - 1)
  
  print(SEG[0])
  
problem_description: Statement
  
  Consider a string of length N consisting of `0` and `1`. The score for the
  string is calculated as follows:
  
    * For each i (1 \leq i \leq M), a_i is added to the score if the string contains `1` at least once between the l_i-th and r_i-th characters (inclusive).
  
  Find the maximum possible score of a string.
samples: [{"input": "5 3\n    1 3 10\n    2 4 -10\n    3 5 10", "output": "20\n    \n\nThe score for `10001` is a_1 + a_3 = 10 + 10 = 20.\n\n* * *"}, {"input": "3 4\n    1 3 100\n    1 1 -10\n    2 2 -20\n    3 3 -30", "output": "90\n    \n\nThe score for `100` is a_1 + a_2 = 100 + (-10) = 90.\n\n* * *"}, {"input": "1 1\n    1 1 -10", "output": "0\n    \n\nThe score for `0` is 0.\n\n* * *"}, {"input": "1 5\n    1 1 1000000000\n    1 1 1000000000\n    1 1 1000000000\n    1 1 1000000000\n    1 1 1000000000", "output": "5000000000\n    \n\nThe answer may not fit into a 32-bit integer type.\n\n* * *"}, {"input": "6 8\n    5 5 3\n    1 1 10\n    1 6 -8\n    3 6 5\n    3 4 9\n    5 5 -2\n    1 3 -6\n    4 6 -7", "output": "10\n    \n\nFor example, the score for `101000` is a_2 + a_3 + a_4 + a_5 + a_7 = 10 + (-8)\n+ 5 + 9 + (-6) = 10."}]