### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

dp = [[[0, None, None, None] for j in range(C + 1)] for i in range(R + 1)]
dp[0][0][0] = 0
dp[0][0][1] = 0

G = [[None for j in range(C)] for i in range(R)]

for _ in range(K):
    r, c, v = map(int, input().split())
    G[r - 1][c - 1] = v

for i in range(R):
    for j in range(C):
        if i == 0:
            break
        if G[i][j] is not None:
            for k in range(4):
                if dp[i][j + 1][k] is not None:
                    dp[i + 1][j + 1][1] = max(dp[i + 1][j + 1][0], dp[i][j + 1][k]) + G[i][j]
                    dp[i + 1][j + 1][0] = max(dp[i + 1][j + 1][0], dp[i][j + 1][k])
        else:
            for k in range(4):
                if dp[i][j + 1][k] is not None:
                    dp[i + 1][j + 1][0] = max(dp[i + 1][j + 1][0], dp[i][j + 1][k])

    for j in range(C):
        if G[i][j] is not None:
            for k in range(3):
                if dp[i + 1][j + 1][k] is not None and dp[i + 1][j][k] is not None:
                    if dp[i + 1][j][k + 1] is not None:
                        if dp[i + 1][j + 1][k + 1] is not None:
                            dp[i + 1][j + 1][k + 1] = max(dp[i + 1][j + 1][k + 1], dp[i + 1][j][k] + G[i][j], dp[i + 1][j][k + 1])
                        else:
                            dp[i + 1][j + 1][k + 1] = max(dp[i + 1][j][k + 1], dp[i + 1][j][k] + G[i][j])
                    else:
                        if dp[i + 1][j + 1][k + 1] is not None:
                            dp[i + 1][j + 1][k + 1] = max(dp[i + 1][j + 1][k + 1], dp[i + 1][j][k] + G[i][j])
                        else:
                            dp[i + 1][j + 1][k + 1] = dp[i + 1][j][k] + G[i][j]
        else:
            for k in range(4):
                if dp[i + 1][j][k] is not None:
                    if dp[i + 1][j + 1][k] is not None:
                        dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k], dp[i + 1][j][k])
                    else:
                        dp[i + 1][j + 1][k] = dp[i + 1][j][k]

res = 0
for d in dp[R][C]:
    if d is not None:
        res = max(res, d)

print(res)

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

R, C, K = map(int, input().split())
G = [[None for j in range(C)] for i in range(R)]

for _ in range(K):
    r, c, v = map(int, input().split())
    G[r - 1][c - 1] = v

dp = [[0, 0, 0, 0] for _ in range(C)]

for i in range(R):
    for j in range(C):
        if G[i][j] is not None:
            dp[j][0], dp[j][1] = max(dp[j]), max(dp[j]) + G[i][j]
            dp[j][2], dp[j][3] = 0, 0
        else:
            dp[j][0] = max(dp[j])
            dp[j][1], dp[j][2], dp[j][3] = 0, 0, 0
    for j in range(1, C):
        if G[i][j] is not None:
            dp[j][0] = max(dp[j - 1][0], dp[j][0])
            dp[j][1] = max(dp[j - 1][1], dp[j - 1][0] + G[i][j], dp[j][1])
            if dp[j - 1][1] != 0:
                dp[j][2] = max(dp[j - 1][2], dp[j - 1][1] + G[i][j], dp[j][2])
            if dp[j - 1][2] != 0:
                dp[j][3] = max(dp[j - 1][3], dp[j - 1][2] + G[i][j], dp[j][3])
        else:
            dp[j][0] = max(dp[j - 1][0], dp[j][0])
            dp[j][1] = max(dp[j - 1][1], dp[j][1])
            dp[j][2] = max(dp[j - 1][2], dp[j][2])
            dp[j][3] = max(dp[j - 1][3], dp[j][3])

print(max(dp[-1]))