def max(a,b); a > b ? a : b; end
H, W, K = gets.split.map(&:to_i)
dp = Array.new(H + 1){ Array.new(W + 1){ Array.new(4,0) } }
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

(1 .. W).each do |x|
  (1 .. H).each do |y|
    if MAP[y][x]
      v = MAP[y][x]
      dp[y][x][1] = max(dp[y - 1][x].max + v, dp[y][x - 1][0] + v)
      dp[y][x][2] = dp[y][x - 1][1] + v
      dp[y][x][3] = dp[y][x - 1][2] + v
    else
      dp[y][x][0] = max(dp[y - 1][x].max, dp[y][x - 1][0])
      dp[y][x][1] = dp[y][x - 1][1]
      dp[y][x][2] = dp[y][x - 1][2]
      dp[y][x][3] = dp[y][x - 1][3]
    end
  end
end
puts dp[H][W].max
