def max(a,b); a > b ? a : b; end

H, W, K = gets.split.map(&:to_i)
MAP = Array.new(H + 1){ Array.new(W + 1) }
K.times do 
  r,c,v = gets.split.map(&:to_i)
  MAP[r][c] = v
end

dpH = (1 .. H).inject(Array.new(W + 1){Array.new(4, 0)}) do |prev, y|
  dp = Array.new(W + 1){Array.new(4, 0)}
  (1 .. W).each do |x|
    if MAP[y][x]
      v = MAP[y][x]
      dp[x][1] = max(dp[x][1], max(prev[x].max + v, dp[x - 1][0] + v))
      dp[x][2] = max(dp[x][2], dp[x - 1][1] + v)
      dp[x][3] = max(dp[x][3], dp[x - 1][2] + v)
    end
    dp[x][0] = max(prev[x].max, dp[x - 1][0])
    dp[x][1] = max(dp[x][1], dp[x - 1][1])
    dp[x][2] = max(dp[x][2], dp[x - 1][2])
    dp[x][3] = max(dp[x][3], dp[x - 1][3])
  end
  dp
end
puts dpH[W].max
