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

puts dp[c-1].max
