r,c,k = gets.split(' ')
r = r.to_i
c = c.to_i
k = k.to_i
array = Array.new(r*c,0)
k.times do
    x,y,v = gets.split(' ')
    x = (x.to_i) -1
    y = (y.to_i) -1
    array[x*c+y] = v.to_i
end
nxt = Array.new(c+1){Array.new(4,0)}
dp = Array.new(c+1){Array.new(4,0)}

for x in 0...r do
    for y in 0...c do
        mx = dp[y].max
        nxt[y][0] = mx
        dp[y+1].each{|item| item = mx}
        sc = array[x*c+y]
        for cnt in 0..2 do
            now = dp[y][cnt]
            nxt[y][0] = now + sc if nxt[y][0] < now +sc
            dp[y+1][cnt+1] = now + sc if dp[y+1][cnt+1] < now + sc
        end
    end
    dp,nxt = nxt,dp
end

puts dp[c-1].max
