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

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

dp = Array.new(R+1){Array.new(C+1){[0]*4}}
R.times do |r|
    C.times do |c|
        row = dp[r]
        cell = row[c]
        2.downto(0).each do |i|
            curr = cell[i] + V[r][c]
            cell[i+1] = curr if cell[i+1] < curr
        end

        up = dp[r+1][c]
        right = row[c+1]
        4.times do |i|
            curr = cell[i]
            up[0] = curr if up[0] < curr
            right[i] = curr if right[i] < curr
        end
    end
end

p dp[R][C-1][0]