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
        for cnt in 0..3 do
            now = dp[y][cnt]
            nxt[y][0] = now if nxt[y][0] < now
            dp[y+1][cnt] = now if dp[y+1][cnt] < now
            sc = array[x*c+y]
            if cnt<=2 then
                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
            #puts "#{x} #{y} #{cnt} #{dp[x][y][cnt]}"
        end
    end
    dp,nxt = nxt,dp
end

puts dp[c-1].max
