import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Array as A

main :: IO ()
main = do
  let
    f :: [Int] -> ((Int, Int), Int)
    f [i, j, v] = ((i, j), v)
    updateR :: (Int, Int, Int, Int) -> Int -> (Int, Int, Int, Int)
    updateR (v0, v1, v2, v3) v = (v0, v1 `max` (v0 + v), v2 `max` (v1 + v), v3 `max` (v2 + v))
    updateC :: (Int, Int, Int, Int) -> Int -> (Int, Int, Int, Int)
    updateC (v0, v1, v2, v3) v = (v', v' + v, v' + v, v' + v)
      where
        v' = maximum [v0, v1, v2, v3] :: Int
    updateRC vR vC v = (v0 `max` v0', v1 `max` v1', v2 `max` v2', v3 `max` v3')
      where
        (v0, v1, v2, v3) = updateR vR v
        (v0', v1', v2', v3') = updateC vC v
  [r, c, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  rcvs <- sequence . replicate k $ f . map unsafeTextToInt . T.words <$> T.getLine :: IO [((Int, Int), Int)]
  let
    vs = A.listArray ((1, 1), (r, c)) (repeat 0) A.// rcvs :: A.Array (Int, Int) Int
    g :: (Int, Int) -> (Int, Int, Int, Int)
    g (i, j) | i == r && j == c = if v == 0 then (0, 0, 0, 0) else (0, v, 0, 0)
             | i == r           = updateR (dp A.! (i, j + 1)) v
             | j == c           = updateC (dp A.! (i + 1, j)) v
             | otherwise        = updateRC (dp A.! (i, j + 1)) (dp A.! (i + 1, j)) v
      where
        v = vs A.! (i, j)
    dp :: A.Array (Int, Int) (Int, Int, Int, Int)
    dp = A.listArray ((1, 1), (r, c)) . map g $ (,) <$> [1..r] <*> [1..c]
  print . (\(_, _, _, v) -> v) . g $ (1, 1)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
