r,c,k = gets.split(' ')
r = r.to_i
c = c.to_i
k = k.to_i
hash = Hash.new
k.times do |i|
    x,y,v = gets.split(' ')
    x = (x.to_i) -1
    y = (y.to_i) -1
    hash[x*c+y] = v.to_i
end
dp = Array.new(r+1){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[x][y][cnt]
            dp[x+1][y][0] = now if dp[x+1][y][0] < now
            dp[x][y+1][cnt] = now if dp[x][y+1][cnt] < now
            sc = hash.fetch(x*c+y,0)
            
            if sc>0 and cnt<=2 then
                dp[x+1][y][0] = now + sc if dp[x+1][y][0] < now +sc
                dp[x][y+1][cnt+1] = now + sc if dp[x][y+1][cnt+1] < now + sc
            end
            #puts "#{x} #{y} #{cnt} #{dp[x][y][cnt]}"
        end
    end
end

puts dp[r][c-1].max