require 'numo/narray'
R,C,K = gets.chomp.split(" ").map(&:to_i)
r,c,v = K.times.map{gets.split.map(&:to_i)}.transpose
value = Array.new(R){Array.new(C,0)}
K.times do |i|
  value[r[i]-1][c[i]-1] = v[i]
end
dp0 = Numo::Int64.new(C+1,4).fill(0)
dp1 = Numo::Int64.new(C+1,4).fill(0)
R.times do |i|
  C.times do |j|
    v = value[i][j]
    if v != 0
      dp0[j,3] = [dp0[j,3],dp0[j,2]+v].max
      dp0[j,2] = [dp0[j,2],dp0[j,1]+v].max
      dp0[j,1] = [dp0[j,1],dp0[j,0]+v].max
    end
    dp1[j,0] = [dp0[j,0],dp0[j,1],dp0[j,2],dp0[j,3]].max

    dp0[j+1,0] = dp0[j,0] if dp0[j+1,0] < dp0[j,0]
    dp0[j+1,1] = dp0[j,1]
    dp0[j+1,2] = dp0[j,2]
    dp0[j+1,3] = dp0[j,3]
  end
  dp0,dp1 = dp1,dp0
end
puts dp0[C-1,0]