r, c, k = gets.split.map(&:to_i)
grid = Array.new(r) { Array.new(c, 0) }
k.times do |i|
  ri, ci, vi = gets.split.map(&:to_i)
  grid[ri - 1][ci - 1] = vi
end

dp = (r + 1).times.map { (c + 1).times.map { Array.new(4, 0) } }
r.times do |up_row|
  dp_up = dp[up_row]
  dp_current = dp[up_row + 1]
  current_grid = grid[up_row]
  c.times do |left_col|
    up_max = dp_up[left_col + 1].last
    dp_current_left_col = dp_current[left_col]
    dp_current_current = dp_current[left_col + 1]
    current_value = current_grid[left_col]
    dp_current_current[0] = up_max
    dp_current_current[0] = dp_current_left_col[0] if dp_current_current[0] < dp_current_left_col[0]
    dp_current_current[1] = up_max + current_value
    dp_current_current[1] = dp_current_left_col[1] if dp_current_current[1] < dp_current_left_col[1]
    dp_current_current[1] = dp_current_left_col[0] + current_value if dp_current_current[1] < dp_current_left_col[0] + current_value
    dp_current_current[2] = up_max + current_value
    dp_current_current[2] = dp_current_left_col[2] if dp_current_current[2] < dp_current_left_col[2]
    dp_current_current[2] = dp_current_left_col[1] + current_value if dp_current_current[2] < dp_current_left_col[1] + current_value
    dp_current_current[3] = up_max + current_value
    dp_current_current[3] = dp_current_left_col[3] if dp_current_current[3] < dp_current_left_col[3]
    dp_current_current[3] = dp_current_left_col[2] + current_value if dp_current_current[3] < dp_current_left_col[2] + current_value
  end
end
puts dp.last.last.max
