# Original solution
# Fast IO (only use in integer input)

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

R,C,K = list(map(int,input().split()))
DP = []
Gift = []
for i in range(R):
    DP.append([])
    Gift.append([])
    for _ in range(C):
        DP[i].append([0,0,0,0])
        Gift[i].append(0)
for _ in range(K):
    r,c,v = list(map(int,input().split()))
    Gift[r-1][c-1] = v

for i in range(R):
    for j in range(C):
        if i != 0 and j != 0:
            DP[i][j][0] = max(DP[i-1][j][0],DP[i-1][j][1],DP[i-1][j][2],DP[i-1][j][3],DP[i][j-1][0])
            DP[i][j][1] = DP[i][j-1][1]
            DP[i][j][2] = DP[i][j-1][2]
            DP[i][j][3] = DP[i][j-1][3]
            if Gift[i][j]:
                DP[i][j][3] = max(DP[i][j][3],DP[i][j][2] + Gift[i][j])
                DP[i][j][2] = max(DP[i][j][2],DP[i][j][1] + Gift[i][j])
                DP[i][j][1] = max(DP[i][j][1],DP[i][j][0] + Gift[i][j])
        elif i == 0:
            DP[i][j][0] = DP[i][j-1][0]
            DP[i][j][1] = DP[i][j-1][1]
            DP[i][j][2] = DP[i][j-1][2]
            DP[i][j][3] = DP[i][j-1][3]
            if Gift[i][j]:
                DP[i][j][3] = max(DP[i][j][3],DP[i][j][2] + Gift[i][j])
                DP[i][j][2] = max(DP[i][j][2],DP[i][j][1] + Gift[i][j])
                DP[i][j][1] = max(DP[i][j][1],DP[i][j][0] + Gift[i][j])
        elif j == 0:
            DP[i][j][0] = max(DP[i-1][j][0],DP[i-1][j][1],DP[i-1][j][2],DP[i-1][j][3])
            if Gift[i][j]:
                DP[i][j][3] = max(DP[i][j][3],DP[i][j][2] + Gift[i][j])
                DP[i][j][2] = max(DP[i][j][2],DP[i][j][1] + Gift[i][j])
                DP[i][j][1] = max(DP[i][j][1],DP[i][j][0] + Gift[i][j])
        else:
            DP[i][j][1] = Gift[i][j]

print((max(DP[R-1][C-1])))

# Optimized solution
# Fast IO (only use in integer input)

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

R,C,K = list(map(int,input().split()))
DP = []
Gift = []
for i in range(R):
    DP.append([])
    Gift.append([])
    for _ in range(C):
        DP[i].append([0,0,0,0])
        Gift[i].append(0)
for _ in range(K):
    r,c,v = list(map(int,input().split()))
    Gift[r-1][c-1] = v

for i in range(R):
    DPi = DP[i]
    for j in range(C):
        DPij = DPi[j]
        if i != 0 and j != 0:
            DPij[0] = max(DP[i-1][j][0],DP[i-1][j][1],DP[i-1][j][2],DP[i-1][j][3],DP[i][j-1][0])
            DPij[1] = DP[i][j-1][1]
            DPij[2] = DP[i][j-1][2]
            DPij[3] = DP[i][j-1][3]
            if Gift[i][j]:
                DPij[3] = max(DPij[3],DPij[2] + Gift[i][j])
                DPij[2] = max(DPij[2],DPij[1] + Gift[i][j])
                DPij[1] = max(DPij[1],DPij[0] + Gift[i][j])
        elif i == 0:
            DPij[0] = DP[i][j-1][0]
            DPij[1] = DP[i][j-1][1]
            DPij[2] = DP[i][j-1][2]
            DPij[3] = DP[i][j-1][3]
            if Gift[i][j]:
                DPij[3] = max(DPij[3],DPij[2] + Gift[i][j])
                DPij[2] = max(DPij[2],DPij[1] + Gift[i][j])
                DPij[1] = max(DPij[1],DPij[0] + Gift[i][j])
        elif j == 0:
            DPij[0] = max(DP[i-1][j][0],DP[i-1][j][1],DP[i-1][j][2],DP[i-1][j][3])
            if Gift[i][j]:
                DPij[3] = max(DPij[3],DPij[2] + Gift[i][j])
                DPij[2] = max(DPij[2],DPij[1] + Gift[i][j])
                DPij[1] = max(DPij[1],DPij[0] + Gift[i][j])
        else:
            DPij[1] = Gift[i][j]

print((max(DP[R-1][C-1])))