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

v = Array.new(r+1) {Array.new(c+1)}
k.times do
    i, j, vv = gets.split.map(&:to_i)
    v[i][j] = vv
end

d = Array.new(r+1) {Array.new(c+1, 0)}

1.upto(r) do |i|
    x = [0,0,0]
    1.upto(c) do |j|
        if v[i][j]
            m = x.min
            if m >= v[i][j]
                y = d[i][j-1]
            else
                x[x.index(m)] = v[i][j]
                y = d[i][j-1] - m + v[i][j]
            end

            z = d[i-1][j] + v[i][j]

            if z >= y
                x = [v[i][j], 0, 0]
                d[i][j] = z
            else
                d[i][j] = y
            end
        else
            if d[i-1][j] >= d[i][j-1]
                x = [0,0,0]
                d[i][j] = d[i-1][j]
            else
                d[i][j] = d[i][j-1]
            end
        end
    end
end

p d[r][c]