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 = Array.new(R){Array.new(C){Array.new(4,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|
      if j != C-1
        dp[i][j+1][k] = [dp[i][j][k], dp[i][j+1][k]].max
        if k != 3
          dp[i][j+1][k+1] = [dp[i][j][k]+value[i][j+1], dp[i][j+1][k+1]].max
        end
      end
      if i != R-1
        dp[i+1][j][0] = [dp[i][j][0..3].max, dp[i+1][j][k]].max
        if k != 3
          dp[i+1][j][1] = [dp[i][j][0..3].max+value[i+1][j], dp[i+1][j][k+1]].max
        end
      end
    end
  end
end
puts dp[R-1][C-1][0..3].max