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

m = Array.new(r+1) {Array.new(c+1, 0)}
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
        d[i][j][0] = x
        d[i][j][1] = x + m[i][j] > d[i][j-1][1] ? x + m[i][j] : d[i][j-1][1]
        d[i][j][2] = d[i][j-1][1] + m[i][j] > d[i][j-1][2] ? d[i][j-1][1] + m[i][j] : d[i][j-1][2]
        d[i][j][3] = d[i][j-1][2] + m[i][j] > d[i][j-1][3] ? d[i][j-1][2] + m[i][j] : d[i][j-1][3]
    end
end

p d[r][c].max