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

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

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

1.upto(r) do |i|
    1.upto(c) do |j|
        x = d[i-1][j].max
        if m[i][j]
            d[i][j][0] = [d[i][j-1][0], x].max
            d[i][j][1] = [d[i][j-1][0] + m[i][j], d[i][j-1][1], x + m[i][j]].max
            d[i][j][2] = [d[i][j-1][1] + m[i][j], d[i][j-1][2]].max
            d[i][j][3] = [d[i][j-1][2] + m[i][j], d[i][j-1][3]].max
        else
            d[i][j][0] = [d[i][j-1][0], x].max
            d[i][j][1] = d[i][j-1][1]
            d[i][j][2] = d[i][j-1][2]
            d[i][j][3] = d[i][j-1][3]
        end
    end
end

p d[r][c].max