R, C, K = map(int,input().split())
MAP = [[0 for i in range(C)] for j in range(R)]
DP = [[[0 for i in range(C+1)] for j in range(4)] for k in range(R+1)]
 
for _ in range(K):
    r, c, v = map(int,input().split())
    MAP[r-1][c-1] = v
 
for i in range(R):
    for j in range(4):
        for k in range(C):
            DP[i+1][j][k+1] = max(DP[i][3][k+1], DP[i+1][j][k])
            if j == 0:
                continue
            v = MAP[i][k]
            if v == 0:
                continue
            DP[i+1][j][k+1] = max(DP[i+1][j][k+1], max(DP[i][3][k+1], DP[i+1][j-1][k]) + v)

print(DP[R][3][C]) R, C, K = map(int,input().split()) R map(int,input().split()) map int input().split() ().split () input split C K [0 for i in range(C)] for j in range(R) for j in range(R) j range(R) range R for j in range(R) [0 for i in range(C)] MAP = [[0 for i in range(C)] for j in range(R)] MAP [[0 for i in range(C)] for j in range(R)] [[0 for i in range(C+1)] for j in range(4)] for k in range(R+1) for k in range(R+1) k range(R+1) range R+1 R 1 for k in range(R+1) [[0 for i in range(C+1)] for j in range(4)] DP = [[[0 for i in range(C+1)] for j in range(4)] for k in range(R+1)] DP [[[0 for i in range(C+1)] for j in range(4)] for k in range(R+1)] for _ in range(K):
    r, c, v = map(int,input().split())
    MAP[r-1][c-1] = v
  _ range(K) range K r, c, v = map(int,input().split()) r map(int,input().split()) map int input().split() ().split () input split c v MAP[r-1][c-1] = v MAP[r-1][c-1] [r-1] MAP r-1 r 1 c-1 c 1 v for i in range(R):
    for j in range(4):
        for k in range(C):
            DP[i+1][j][k+1] = max(DP[i][3][k+1], DP[i+1][j][k])
            if j == 0:
                continue
            v = MAP[i][k]
            if v == 0:
                continue
            DP[i+1][j][k+1] = max(DP[i+1][j][k+1], max(DP[i][3][k+1], DP[i+1][j-1][k]) + v) i range(R) range R for j in range(4):
        for k in range(C):
            DP[i+1][j][k+1] = max(DP[i][3][k+1], DP[i+1][j][k])
            if j == 0:
                continue
            v = MAP[i][k]
            if v == 0:
                continue
            DP[i+1][j][k+1] = max(DP[i+1][j][k+1], max(DP[i][3][k+1], DP[i+1][j-1][k]) + v) j range(4) range 4 for k in range(C):
            DP[i+1][j][k+1] = max(DP[i][3][k+1], DP[i+1][j][k])
            if j == 0:
                continue
            v = MAP[i][k]
            if v == 0:
                continue
            DP[i+1][j][k+1] = max(DP[i+1][j][k+1], max(DP[i][3][k+1], DP[i+1][j-1][k]) + v) k range(C) range C DP[i+1][j][k+1] = max(DP[i][3][k+1], DP[i+1][j][k]) DP[i+1][j][k+1] [j] [i+1] DP i+1 i 1 j k+1 k 1 max(DP[i][3][k+1], DP[i+1][j][k]) max DP[i][3][k+1] [3] [i] DP i 3 k+1 k 1 DP[i+1][j][k] [j] [i+1] DP i+1 i 1 j k if j == 0:
                continue
             j == 0 j 0 continue v = MAP[i][k] v MAP[i][k] [i] MAP i k if v == 0:
                continue
             v == 0 v 0 continue DP[i+1][j][k+1] = max(DP[i+1][j][k+1], max(DP[i][3][k+1], DP[i+1][j-1][k]) + v) DP[i+1][j][k+1] [j] [i+1] DP i+1 i 1 j k+1 k 1 max(DP[i+1][j][k+1], max(DP[i][3][k+1], DP[i+1][j-1][k]) + v) max DP[i+1][j][k+1] [j] [i+1] DP i+1 i 1 j k+1 k 1 max(DP[i][3][k+1], DP[i+1][j-1][k]) + v max(DP[i][3][k+1], DP[i+1][j-1][k]) max DP[i][3][k+1] [3] [i] DP i 3 k+1 k 1 DP[i+1][j-1][k] [j-1] [i+1] DP i+1 i 1 j-1 j 1 k v print(DP[R][3][C]) print DP[R][3][C] [3] [R] DP R 3 C v = map(int,input().split()) map(int,input().split()) v r, c, v = map(int,input().split()) map(int,input().split()) r R, C, K = map(int,input().split()) map(int,input().split()) R MAP = [[0 for i in range(C)] for j in range(R)] [[0 for i in range(C)] for j in range(R)] MAP v = MAP[i][k] MAP[i][k] v DP = [[[0 for i in range(C+1)] for j in range(4)] for k in range(R+1)] [[[0 for i in range(C+1)] for j in range(4)] for k in range(R+1)] DP C, K = map(int,input().split()) map(int,input().split()) C c, v = map(int,input().split()) map(int,input().split()) c K = map(int,input().split()) map(int,input().split()) K
R, C, K = map(int,input().split())
MAP = [[0 for i in range(C)] for j in range(R)]
DP = [[[0 for i in range(C+1)] for j in range(4)] for k in range(R+1)]
 
for _ in range(K):
    r, c, v = map(int,input().split())
    MAP[r-1][c-1] = v
 
for i in range(R):
    for j in range(4):
        for k in range(C):
            DP[i+1][j][k+1] = max(DP[i][3][k+1], DP[i+1][j][k])
            if j == 0:
                continue
            v = MAP[i][k]
            if v == 0:
                continue
            DP[i+1][j][k+1] = max(DP[i+1][j][k+1], max(DP[i][3][k+1], DP[i+1][j-1][k]) + v)

print(DP[R][3][C])
