R,C,K = gets.split.map &:to_i
RCV = K.times.map{ gets.split.map(&:to_i)}

V = Array.new(R){[]}
RCV.each do |r,c,v|
    V[r-1][c-1] = v
end

row = Array.new(C+1){[0] * 4}
row_up = Array.new(C+1){[0] * 4}
R.times do |r|
    C.times do |c|
        cell = row[c]
        v = V[r][c]
        if v then
            2.downto(0) do |i|
                cell[i+1] = [cell[i+1], cell[i] + v].max
            end
        end

        row_up[c][0] = cell.max
        right = row[c+1]
        right[0] = cell[0] if right[0] < cell[0]
        right[1] = cell[1]
        right[2] = cell[2]
        right[3] = cell[3]
    end

    row,row_up = row_up,row
end

p row[C-1][0]