### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():

    R, C, K = map(int, input().split())

    # row2item = {r: [0]*C for r in range(R)}
    #  # r -> index, col, val
    item_map = [[0]*C for _ in range(R)]

    for i in range(K):
        ir, ic, iv = map(int, input().split())
        item_map[ir-1][ic-1] = iv

    dp = []
    for row in range(R):
        ls = []
        for col in range(C):
            ls.append([0, 0, 0, 0])
        dp.append(ls)

    for row in range(R):
        for col in range(C):
            if row == 0 and col == 0:
                if item_map[row][col] != 0:
                    dp[row][col][1] = item_map[row][col]
            elif row == 0:
                dp[row][col][0] = dp[row][col-1][0]
                if item_map[row][col] == 0:
                    dp[row][col][1] = dp[row][col-1][1]
                    dp[row][col][2] = dp[row][col-1][2]
                    dp[row][col][3] = dp[row][col-1][3]
                else:
                    dp[row][col][1] = max(dp[row][col-1][1], dp[row][col-1][0] + item_map[row][col])
                    dp[row][col][2] = max(dp[row][col-1][2], dp[row][col-1][1] + item_map[row][col])
                    dp[row][col][3] = max(dp[row][col-1][3], dp[row][col-1][2] + item_map[row][col])
            elif col == 0:
                dp[row][col][0] = max(
                    dp[row-1][col][0], dp[row-1][col][1], dp[row-1][col][2], dp[row-1][col][3])
                
                if item_map[row][col] != 0:
                    dp[row][col][1] = dp[row][col][0] + item_map[row][col]
            else:
                dp[row][col][0] = max(
                    dp[row][col-1][0],
                    dp[row-1][col][0],
                    dp[row-1][col][1],
                    dp[row-1][col][2],
                    dp[row-1][col][3])
                if item_map[row][col] == 0:
                    dp[row][col][1] = dp[row][col-1][1]
                    dp[row][col][2] = dp[row][col-1][2]
                    dp[row][col][3] = dp[row][col-1][3]
                else:
                    dp[row][col][1] = max(
                        dp[row-1][col][0] + item_map[row][col], 
                        dp[row-1][col][1] + item_map[row][col],
                        dp[row-1][col][2] + item_map[row][col],
                        dp[row-1][col][3] + item_map[row][col],
                        dp[row][col-1][0] + item_map[row][col],
                        dp[row][col-1][1]
                        )
                    dp[row][col][2] = max(
                        dp[row][col-1][1] + item_map[row][col],
                        dp[row][col-1][2]
                        )
                    dp[row][col][3] = max(
                        dp[row][col-1][2] + item_map[row][col],
                        dp[row][col-1][3]
                        )
    print(max(dp[R-1][C-1]))
main()

### FIXED CODE ###

R, C,K = map(int, input().split())
dp = [[[0]*(C+1) for k in range(R+1)] for _ in range(4)]
# dp[r][c][j] :=r index c columns already j cnt
dp[0][0][0] = 0
D = [[0 for i in range(C+1)] for j in range(R+1)]
import random
for i in range(K):
    r, c, v = map(int,input().split())
    D[r][c] = v
 
for i in range(R+1):
    for j in range(C+1):
        if D[i][j] > 0:
            v = D[i][j]
            M = max(dp[k][i-1][j] for k in range(4))
            dp[0][i][j] = max(dp[0][i][j-1], M)
            dp[1][i][j] = max(dp[0][i][j-1]+v, dp[1][i][j-1], M+v)
            dp[2][i][j] = max(dp[1][i][j-1]+v, dp[2][i][j-1])
            dp[3][i][j] = max(dp[2][i][j-1]+v, dp[3][i][j-1])
 
        else:
            M = max(dp[k][i-1][j] for k in range(4))
            dp[0][i][j] = max(dp[0][i][j-1], M)
            dp[1][i][j] = dp[1][i][j-1]
            dp[2][i][j] = dp[2][i][j-1]
            dp[3][i][j] = dp[3][i][j-1]
 
ans = 0
for i in range(4):
    ans = max(ans, dp[i][-1][-1])
print(ans)