h,w,k = map(int, input().split())
item = [[0 for _ in range(w)] for _ in range(h)]
for i in range(k):
    y,x,v = list(map(int,input().split()))
    item[y-1][x-1]=v

dp = [[[0 for _ in range(w+1)] for _ in range(h+1)] for _ in range(4)]

for y in range(h):
    for x in range(w):
        for i in range(4):
            dp[0][y+1][x]=max(dp[0][y+1][x],dp[i][y][x])
            dp[i][y][x+1]=max(dp[i][y][x+1],dp[i][y][x])
        if item[y][x]>0:
            for i in range(3):
                dp[0][y+1][x]  =max(dp[0][y+1][x],  dp[i][y][x]+item[y][x])
                dp[i+1][y][x+1]=max(dp[i+1][y][x+1],dp[i][y][x]+item[y][x])
ans=dp[0][-1][-2]
print(ans) h,w,k = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w k [0 for _ in range(w)] for _ in range(h) for _ in range(h) _ range(h) range h for _ in range(h) [0 for _ in range(w)] item = [[0 for _ in range(w)] for _ in range(h)] item [[0 for _ in range(w)] for _ in range(h)] for i in range(k):
    y,x,v = list(map(int,input().split()))
    item[y-1][x-1]=v i range(k) range k y,x,v = list(map(int,input().split())) y list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split x v item[y-1][x-1]=v item[y-1][x-1] [y-1] item y-1 y 1 x-1 x 1 v [[0 for _ in range(w+1)] for _ in range(h+1)] for _ in range(4) for _ in range(4) _ range(4) range 4 for _ in range(4) [[0 for _ in range(w+1)] for _ in range(h+1)] dp = [[[0 for _ in range(w+1)] for _ in range(h+1)] for _ in range(4)] dp [[[0 for _ in range(w+1)] for _ in range(h+1)] for _ in range(4)] for y in range(h):
    for x in range(w):
        for i in range(4):
            dp[0][y+1][x]=max(dp[0][y+1][x],dp[i][y][x])
            dp[i][y][x+1]=max(dp[i][y][x+1],dp[i][y][x])
        if item[y][x]>0:
            for i in range(3):
                dp[0][y+1][x]  =max(dp[0][y+1][x],  dp[i][y][x]+item[y][x])
                dp[i+1][y][x+1]=max(dp[i+1][y][x+1],dp[i][y][x]+item[y][x]) y range(h) range h for x in range(w):
        for i in range(4):
            dp[0][y+1][x]=max(dp[0][y+1][x],dp[i][y][x])
            dp[i][y][x+1]=max(dp[i][y][x+1],dp[i][y][x])
        if item[y][x]>0:
            for i in range(3):
                dp[0][y+1][x]  =max(dp[0][y+1][x],  dp[i][y][x]+item[y][x])
                dp[i+1][y][x+1]=max(dp[i+1][y][x+1],dp[i][y][x]+item[y][x]) x range(w) range w for i in range(4):
            dp[0][y+1][x]=max(dp[0][y+1][x],dp[i][y][x])
            dp[i][y][x+1]=max(dp[i][y][x+1],dp[i][y][x])
         i range(4) range 4 dp[0][y+1][x]=max(dp[0][y+1][x],dp[i][y][x]) dp[0][y+1][x] [y+1] [0] dp 0 y+1 y 1 x max(dp[0][y+1][x],dp[i][y][x]) max dp[0][y+1][x] [y+1] [0] dp 0 y+1 y 1 x dp[i][y][x] [y] [i] dp i y x dp[i][y][x+1]=max(dp[i][y][x+1],dp[i][y][x]) dp[i][y][x+1] [y] [i] dp i y x+1 x 1 max(dp[i][y][x+1],dp[i][y][x]) max dp[i][y][x+1] [y] [i] dp i y x+1 x 1 dp[i][y][x] [y] [i] dp i y x if item[y][x]>0:
            for i in range(3):
                dp[0][y+1][x]  =max(dp[0][y+1][x],  dp[i][y][x]+item[y][x])
                dp[i+1][y][x+1]=max(dp[i+1][y][x+1],dp[i][y][x]+item[y][x]) item[y][x]>0 item[y][x] [y] item y x 0 for i in range(3):
                dp[0][y+1][x]  =max(dp[0][y+1][x],  dp[i][y][x]+item[y][x])
                dp[i+1][y][x+1]=max(dp[i+1][y][x+1],dp[i][y][x]+item[y][x]) i range(3) range 3 dp[0][y+1][x]  =max(dp[0][y+1][x],  dp[i][y][x]+item[y][x]) dp[0][y+1][x] [y+1] [0] dp 0 y+1 y 1 x max(dp[0][y+1][x],  dp[i][y][x]+item[y][x]) max dp[0][y+1][x] [y+1] [0] dp 0 y+1 y 1 x dp[i][y][x]+item[y][x] dp[i][y][x] [y] [i] dp i y x item[y][x] [y] item y x dp[i+1][y][x+1]=max(dp[i+1][y][x+1],dp[i][y][x]+item[y][x]) dp[i+1][y][x+1] [y] [i+1] dp i+1 i 1 y x+1 x 1 max(dp[i+1][y][x+1],dp[i][y][x]+item[y][x]) max dp[i+1][y][x+1] [y] [i+1] dp i+1 i 1 y x+1 x 1 dp[i][y][x]+item[y][x] dp[i][y][x] [y] [i] dp i y x item[y][x] [y] item y x ans=dp[0][-1][-2] ans dp[0][-1][-2] [-1] [0] dp 0 -1 -2 print(ans) print ans h,w,k = map(int, input().split()) map(int, input().split()) h w,k = map(int, input().split()) map(int, input().split()) w k = map(int, input().split()) map(int, input().split()) k x,v = list(map(int,input().split())) list(map(int,input().split())) x y,x,v = list(map(int,input().split())) list(map(int,input().split())) y dp = [[[0 for _ in range(w+1)] for _ in range(h+1)] for _ in range(4)] [[[0 for _ in range(w+1)] for _ in range(h+1)] for _ in range(4)] dp v = list(map(int,input().split())) list(map(int,input().split())) v item = [[0 for _ in range(w)] for _ in range(h)] [[0 for _ in range(w)] for _ in range(h)] item ans=dp[0][-1][-2] dp[0][-1][-2] ans
h,w,k = map(int, input().split())
item = [[0 for _ in range(w)] for _ in range(h)]
for i in range(k):
    y,x,v = list(map(int,input().split()))
    item[y-1][x-1]=v

dp = [[[0 for _ in range(w+1)] for _ in range(h+1)] for _ in range(4)]

for y in range(h):
    for x in range(w):
        for i in range(4):
            dp[0][y+1][x]=max(dp[0][y+1][x],dp[i][y][x])
            dp[i][y][x+1]=max(dp[i][y][x+1],dp[i][y][x])
        if item[y][x]>0:
            for i in range(3):
                dp[0][y+1][x]  =max(dp[0][y+1][x],  dp[i][y][x]+item[y][x])
                dp[i+1][y][x+1]=max(dp[i+1][y][x+1],dp[i][y][x]+item[y][x])
ans=dp[0][-1][-2]
print(ans)