c=[[0]*3001for _ in range(3001)]
dp=[[[0]*3001for _ in range(3001)]for _ in range(4)]
h,w,k=map(int,input().split())
for i in range(k):
    y,x,v=map(int,input().split())
    c[y][x]=v
for i in range(1,h+1):
    for j in range(1,w+1):
        x=max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j])
        for k in range(4):
            if k:dp[k][i][j]=max(dp[k][i][j-1],dp[k-1][i][j-1]+c[i][j])
            else:dp[k][i][j]=max(dp[k][i][j-1],x)
        dp[1][i][j]=max(dp[1][i][j],x+c[i][j])
print(max(dp[0][h][w],dp[1][h][w],dp[2][h][w],dp[3][h][w])) [0]*3001for _ in range(3001) for _ in range(3001) _ range(3001) range 3001 for _ in range(3001) [0]*3001 [0] 0 3001 c=[[0]*3001for _ in range(3001)] c [[0]*3001for _ in range(3001)] [[0]*3001for _ in range(3001)]for _ in range(4) for _ in range(4) _ range(4) range 4 for _ in range(4) [[0]*3001for _ in range(3001)] dp=[[[0]*3001for _ in range(3001)]for _ in range(4)] dp [[[0]*3001for _ in range(3001)]for _ in range(4)] h,w,k=map(int,input().split()) h map(int,input().split()) map int input().split() ().split () input split w k for i in range(k):
    y,x,v=map(int,input().split())
    c[y][x]=v i range(k) range k y,x,v=map(int,input().split()) y map(int,input().split()) map int input().split() ().split () input split x v c[y][x]=v c[y][x] [y] c y x v for i in range(1,h+1):
    for j in range(1,w+1):
        x=max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j])
        for k in range(4):
            if k:dp[k][i][j]=max(dp[k][i][j-1],dp[k-1][i][j-1]+c[i][j])
            else:dp[k][i][j]=max(dp[k][i][j-1],x)
        dp[1][i][j]=max(dp[1][i][j],x+c[i][j]) i range(1,h+1) range 1 h+1 h 1 for j in range(1,w+1):
        x=max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j])
        for k in range(4):
            if k:dp[k][i][j]=max(dp[k][i][j-1],dp[k-1][i][j-1]+c[i][j])
            else:dp[k][i][j]=max(dp[k][i][j-1],x)
        dp[1][i][j]=max(dp[1][i][j],x+c[i][j]) j range(1,w+1) range 1 w+1 w 1 x=max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j]) x max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j]) max dp[0][i-1][j] [i-1] [0] dp 0 i-1 i 1 j dp[1][i-1][j] [i-1] [1] dp 1 i-1 i 1 j dp[2][i-1][j] [i-1] [2] dp 2 i-1 i 1 j dp[3][i-1][j] [i-1] [3] dp 3 i-1 i 1 j for k in range(4):
            if k:dp[k][i][j]=max(dp[k][i][j-1],dp[k-1][i][j-1]+c[i][j])
            else:dp[k][i][j]=max(dp[k][i][j-1],x)
         k range(4) range 4 if k:dp[k][i][j]=max(dp[k][i][j-1],dp[k-1][i][j-1]+c[i][j])
            else:dp[k][i][j]=max(dp[k][i][j-1],x)
         k dp[1][i][j]=max(dp[1][i][j],x+c[i][j]) dp[1][i][j] [i] [1] dp 1 i j max(dp[1][i][j],x+c[i][j]) max dp[1][i][j] [i] [1] dp 1 i j x+c[i][j] x c[i][j] [i] c i j print(max(dp[0][h][w],dp[1][h][w],dp[2][h][w],dp[3][h][w])) print max(dp[0][h][w],dp[1][h][w],dp[2][h][w],dp[3][h][w]) max dp[0][h][w] [h] [0] dp 0 h w dp[1][h][w] [h] [1] dp 1 h w dp[2][h][w] [h] [2] dp 2 h w dp[3][h][w] [h] [3] dp 3 h w v=map(int,input().split()) map(int,input().split()) v w,k=map(int,input().split()) map(int,input().split()) w x,v=map(int,input().split()) map(int,input().split()) x x=max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j]) max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j]) x c=[[0]*3001for _ in range(3001)] [[0]*3001for _ in range(3001)] c h,w,k=map(int,input().split()) map(int,input().split()) h dp=[[[0]*3001for _ in range(3001)]for _ in range(4)] [[[0]*3001for _ in range(3001)]for _ in range(4)] dp y,x,v=map(int,input().split()) map(int,input().split()) y k=map(int,input().split()) map(int,input().split()) k
c=[[0]*3001for _ in range(3001)]
dp=[[[0]*3001for _ in range(3001)]for _ in range(4)]
h,w,k=map(int,input().split())
for i in range(k):
    y,x,v=map(int,input().split())
    c[y][x]=v
for i in range(1,h+1):
    for j in range(1,w+1):
        x=max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j])
        for k in range(4):
            if k:dp[k][i][j]=max(dp[k][i][j-1],dp[k-1][i][j-1]+c[i][j])
            else:dp[k][i][j]=max(dp[k][i][j-1],x)
        dp[1][i][j]=max(dp[1][i][j],x+c[i][j])
print(max(dp[0][h][w],dp[1][h][w],dp[2][h][w],dp[3][h][w]))