r, c, k = gets.split.map(&:to_i)

v = {}
k.times do
    i, j, vv = gets.split.map(&:to_i)
    v[(i << 13) + j] = vv
end

dp = Array.new(c+1) {Array.new(4,0)}
s = Array.new(c+1) {Array.new(4,0)}

1.upto(r) do |i|
    1.upto(c) do |j|
        vv = v[(i << 13) + j]

        dp[j][0] = dp[j-1][0] if dp[j][0] < dp[j-1][0]
        dp[j][1,3] = dp[j-1][1,3]
        3.downto(1) {|m| dp[j][m] = dp[j][m-1] + vv if dp[j][m] < dp[j][m-1] + vv} if vv

        s[j][0] = dp[j].max
    end
    dp, s = s, dp
end

p dp[c][0]
