r, c, k = map(int, input().split())

dp = [[[0,0,0,0] for _j in range(c+1)] for _i in range(2)]
bord = [[0]*(c+1) for _i in range(r)]

for _i in range(k):
    _r, _c, _v = map(int, input().split())
    bord[_r-1][_c-1] = _v
            
for i in range(r):
    for j in range(c):
        dp[1][j][0] = max(dp[0][j])
        dp[1][j][1] = max(
            dp[1][j][0] + bord[i][j],
            dp[1][j-1][1],
            dp[1][j-1][0]+bord[i][j]
        )

        dp[1][j][2] = max(
            dp[1][j-1][2],
            dp[1][j-1][1]+bord[i][j],             
        )
        dp[1][j][3] = max(
            dp[1][j-1][3],
            dp[1][j-1][2]+bord[i][j],             
        )

    dp[0] = dp[1][::]

print(max(dp[1][c-1])) r, c, k = map(int, input().split()) r map(int, input().split()) map int input().split() ().split () input split c k [[0,0,0,0] for _j in range(c+1)] for _i in range(2) for _i in range(2) _i range(2) range 2 for _i in range(2) [[0,0,0,0] for _j in range(c+1)] dp = [[[0,0,0,0] for _j in range(c+1)] for _i in range(2)] dp [[[0,0,0,0] for _j in range(c+1)] for _i in range(2)] [0]*(c+1) for _i in range(r) for _i in range(r) _i range(r) range r for _i in range(r) [0]*(c+1) [0] 0 c+1 c 1 bord = [[0]*(c+1) for _i in range(r)] bord [[0]*(c+1) for _i in range(r)] for _i in range(k):
    _r, _c, _v = map(int, input().split())
    bord[_r-1][_c-1] = _v
             _i range(k) range k _r, _c, _v = map(int, input().split()) _r map(int, input().split()) map int input().split() ().split () input split _c _v bord[_r-1][_c-1] = _v bord[_r-1][_c-1] [_r-1] bord _r-1 _r 1 _c-1 _c 1 _v for i in range(r):
    for j in range(c):
        dp[1][j][0] = max(dp[0][j])
        dp[1][j][1] = max(
            dp[1][j][0] + bord[i][j],
            dp[1][j-1][1],
            dp[1][j-1][0]+bord[i][j]
        )

        dp[1][j][2] = max(
            dp[1][j-1][2],
            dp[1][j-1][1]+bord[i][j],             
        )
        dp[1][j][3] = max(
            dp[1][j-1][3],
            dp[1][j-1][2]+bord[i][j],             
        )

    dp[0] = dp[1][::] i range(r) range r for j in range(c):
        dp[1][j][0] = max(dp[0][j])
        dp[1][j][1] = max(
            dp[1][j][0] + bord[i][j],
            dp[1][j-1][1],
            dp[1][j-1][0]+bord[i][j]
        )

        dp[1][j][2] = max(
            dp[1][j-1][2],
            dp[1][j-1][1]+bord[i][j],             
        )
        dp[1][j][3] = max(
            dp[1][j-1][3],
            dp[1][j-1][2]+bord[i][j],             
        )

     j range(c) range c dp[1][j][0] = max(dp[0][j]) dp[1][j][0] [j] [1] dp 1 j 0 max(dp[0][j]) max dp[0][j] [0] dp 0 j dp[1][j][1] = max(
            dp[1][j][0] + bord[i][j],
            dp[1][j-1][1],
            dp[1][j-1][0]+bord[i][j]
        ) dp[1][j][1] [j] [1] dp 1 j 1 max(
            dp[1][j][0] + bord[i][j],
            dp[1][j-1][1],
            dp[1][j-1][0]+bord[i][j]
        ) max dp[1][j][0] + bord[i][j] dp[1][j][0] [j] [1] dp 1 j 0 bord[i][j] [i] bord i j dp[1][j-1][1] [j-1] [1] dp 1 j-1 j 1 1 dp[1][j-1][0]+bord[i][j] dp[1][j-1][0] [j-1] [1] dp 1 j-1 j 1 0 bord[i][j] [i] bord i j dp[1][j][2] = max(
            dp[1][j-1][2],
            dp[1][j-1][1]+bord[i][j],             
        ) dp[1][j][2] [j] [1] dp 1 j 2 max(
            dp[1][j-1][2],
            dp[1][j-1][1]+bord[i][j],             
        ) max dp[1][j-1][2] [j-1] [1] dp 1 j-1 j 1 2 dp[1][j-1][1]+bord[i][j] dp[1][j-1][1] [j-1] [1] dp 1 j-1 j 1 1 bord[i][j] [i] bord i j dp[1][j][3] = max(
            dp[1][j-1][3],
            dp[1][j-1][2]+bord[i][j],             
        ) dp[1][j][3] [j] [1] dp 1 j 3 max(
            dp[1][j-1][3],
            dp[1][j-1][2]+bord[i][j],             
        ) max dp[1][j-1][3] [j-1] [1] dp 1 j-1 j 1 3 dp[1][j-1][2]+bord[i][j] dp[1][j-1][2] [j-1] [1] dp 1 j-1 j 1 2 bord[i][j] [i] bord i j dp[0] = dp[1][::] dp[0] dp 0 dp[1][::] [1] dp 1 :: print(max(dp[1][c-1])) print max(dp[1][c-1]) max dp[1][c-1] [1] dp 1 c-1 c 1 _c, _v = map(int, input().split()) map(int, input().split()) _c k = map(int, input().split()) map(int, input().split()) k r, c, k = map(int, input().split()) map(int, input().split()) r c, k = map(int, input().split()) map(int, input().split()) c _v = map(int, input().split()) map(int, input().split()) _v dp = [[[0,0,0,0] for _j in range(c+1)] for _i in range(2)] [[[0,0,0,0] for _j in range(c+1)] for _i in range(2)] dp bord = [[0]*(c+1) for _i in range(r)] [[0]*(c+1) for _i in range(r)] bord _r, _c, _v = map(int, input().split()) map(int, input().split()) _r
r, c, k = map(int, input().split())

dp = [[[0,0,0,0] for _j in range(c+1)] for _i in range(2)]
bord = [[0]*(c+1) for _i in range(r)]

for _i in range(k):
    _r, _c, _v = map(int, input().split())
    bord[_r-1][_c-1] = _v
            
for i in range(r):
    for j in range(c):
        dp[1][j][0] = max(dp[0][j])
        dp[1][j][1] = max(
            dp[1][j][0] + bord[i][j],
            dp[1][j-1][1],
            dp[1][j-1][0]+bord[i][j]
        )

        dp[1][j][2] = max(
            dp[1][j-1][2],
            dp[1][j-1][1]+bord[i][j],             
        )
        dp[1][j][3] = max(
            dp[1][j-1][3],
            dp[1][j-1][2]+bord[i][j],             
        )

    dp[0] = dp[1][::]

print(max(dp[1][c-1]))