r, c, k = gets.chomp.split(' ').map(&:to_i)
v = (0...r).map { (0...c).map { 0 }}
(0...k).each do
  ro, co, va = gets.chomp.split(' ').map(&:to_i)
  v[ro - 1][co - 1] = va
end

dp = (0...r).map { (0...c).map { (0..3).map { 0 } }}

(0...r).each do |i|
  (0...c).each do |j|
    if j == 0
      if i == 0
        dp[i][j][0] = 0
        dp[i][j][1] = v[0][0]
        dp[i][j][2] = -1e99
        dp[i][j][3] = -1e99
      else
        dp[i][j][0] = dp[i - 1][j].max
        dp[i][j][1] = dp[i - 1][j].max + v[i][j]
        dp[i][j][2] = -1e99
        dp[i][j][3] = -1e99
      end
    else
      if i == 0
        dp[i][j][0] = dp[i][j - 1][0]
        dp[i][j][1] = [dp[i][j - 1][1], dp[i][j - 1][0] + v[i][j]].max
        dp[i][j][2] = [dp[i][j - 1][2], dp[i][j - 1][1] + v[i][j]].max
        dp[i][j][3] = [dp[i][j - 1][3], dp[i][j - 1][2] + v[i][j]].max
      else
        dp[i][j][0] = [dp[i][j - 1][0], dp[i - 1][j].max].max
        dp[i][j][1] = [dp[i][j - 1][1], dp[i][j - 1][0] + v[i][j], dp[i - 1][j].max + v[i][j]].max
        dp[i][j][2] = [dp[i][j - 1][2], dp[i][j - 1][1] + v[i][j]].max
        dp[i][j][3] = [dp[i][j - 1][3], dp[i][j - 1][2] + v[i][j]].max
      end
    end
  end
end

puts dp[r - 1][c - 1].max
