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 = Array.new(R){Array.new(C,0)}
dp1 = Array.new(R){Array.new(C,0)}
dp2 = Array.new(R){Array.new(C,0)}
dp3 = Array.new(R){Array.new(C,0)}
dp0[0][0] = 0
dp1[0][0] = value[0][0]
R.times do |i|
  C.times do |j|
    if i != R-1
      dp0[i+1][j] = dp0[i][j] if dp0[i+1][j] < dp0[i][j]
      dp0[i+1][j] = dp1[i][j] if dp0[i+1][j] < dp1[i][j]
      dp0[i+1][j] = dp2[i][j] if dp0[i+1][j] < dp2[i][j]
      dp0[i+1][j] = dp3[i][j] if dp0[i+1][j] < dp3[i][j]
      dp1[i+1][j] = dp0[i][j]+value[i+1][j] if dp1[i+1][j] < dp0[i][j]+value[i+1][j]
      dp1[i+1][j] = dp1[i][j]+value[i+1][j] if dp1[i+1][j] < dp1[i][j]+value[i+1][j]
      dp1[i+1][j] = dp2[i][j]+value[i+1][j] if dp1[i+1][j] < dp2[i][j]+value[i+1][j]
      dp1[i+1][j] = dp3[i][j]+value[i+1][j] if dp1[i+1][j] < dp3[i][j]+value[i+1][j]
    end
  end
end
puts [dp0[R-1][C-1],dp1[R-1][C-1],dp2[R-1][C-1],dp3[R-1][C-1]].max
