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+1){Array.new(C+1,0)}
K.times do |i|
  value[r[i]-1][c[i]-1] = v[i]
end
dp = Numo::Int64.new(R+1,C+1,5).fill(0)
dp[0,0,0] = 0
dp[0,0,1] = value[0][0]
R.times do |i|
  C.times do |j|
    4.times do |k|
      dp[i,j+1,k] = [dp[i,j,k], dp[i,j+1,k]].max
      dp[i,j+1,k+1] = [dp[i,j,k]+value[i][j+1], dp[i,j+1,k+1]].max
      dp[i+1,j,0] = [dp[i,j,0],dp[i,j,1],dp[i,j,2],dp[i,j,3],dp[i+1,j,k]].max
      dp[i+1,j,1] = [dp[i,j,0]+value[i+1][j],dp[i,j,1]+value[i+1][j],dp[i,j,2]+value[i+1][j],dp[i,j,3]+value[i+1][j],dp[i+1,j,k+1]].max
    end
  end
end
puts dp[R-1,C-1,0..3].max
