f,g,h=range,max,input
R,C,K=map(int,h().split())
G=[[0]*-~C for i in f(R+1)]
for i in'_'*K:r,c,v=map(int,h().split());G[r][c]=v
F=[[[0]*-~C for i in f(R+1)]for i in f(4)]
for r in f(1,R+1):
	for x in f(1,4):
		for c in f(1,C+1):F[x][r][c]=g(F[x-1][r][c],F[x-1][r][c-1]+G[r][c],F[x][r][c-1],(x<2)*(G[r][c]+g(F[1][r-1][c],F[2][r-1][c],F[3][r-1][c])))
print(F[3][R][C]) f,g,h=range,max,input f range g max h input R,C,K=map(int,h().split()) R map(int,h().split()) map int h().split() ().split () h split C K [0]*-~C for i in f(R+1) for i in f(R+1) i f(R+1) f R+1 R 1 for i in f(R+1) [0]*-~C [0] 0 -~C ~C C G=[[0]*-~C for i in f(R+1)] G [[0]*-~C for i in f(R+1)] for i in'_'*K:r,c,v=map(int,h().split());G[r][c]=v i '_'*K '_' K [[0]*-~C for i in f(R+1)]for i in f(4) for i in f(4) i f(4) f 4 for i in f(4) [[0]*-~C for i in f(R+1)] F=[[[0]*-~C for i in f(R+1)]for i in f(4)] F [[[0]*-~C for i in f(R+1)]for i in f(4)] for r in f(1,R+1):
	for x in f(1,4):
		for c in f(1,C+1):F[x][r][c]=g(F[x-1][r][c],F[x-1][r][c-1]+G[r][c],F[x][r][c-1],(x<2)*(G[r][c]+g(F[1][r-1][c],F[2][r-1][c],F[3][r-1][c]))) r f(1,R+1) f 1 R+1 R 1 for x in f(1,4):
		for c in f(1,C+1):F[x][r][c]=g(F[x-1][r][c],F[x-1][r][c-1]+G[r][c],F[x][r][c-1],(x<2)*(G[r][c]+g(F[1][r-1][c],F[2][r-1][c],F[3][r-1][c]))) x f(1,4) f 1 4 for c in f(1,C+1):F[x][r][c]=g(F[x-1][r][c],F[x-1][r][c-1]+G[r][c],F[x][r][c-1],(x<2)*(G[r][c]+g(F[1][r-1][c],F[2][r-1][c],F[3][r-1][c]) c f(1,C+1) f 1 C+1 C 1 print(F[3][R][C]) print F[3][R][C] [R] [3] F 3 R C C,K=map(int,h().split()) map(int,h().split()) C h=range,max,input input h K=map(int,h().split()) map(int,h().split()) K f,g,h=range,max,input range f g,h=range,max,input max g R,C,K=map(int,h().split()) map(int,h().split()) R G=[[0]*-~C for i in f(R+1)] [[0]*-~C for i in f(R+1)] G F=[[[0]*-~C for i in f(R+1)]for i in f(4)] [[[0]*-~C for i in f(R+1)]for i in f(4)] F
f,g,h=range,max,input
R,C,K=map(int,h().split())
G=[[0]*-~C for i in f(R+1)]
for i in'_'*K:r,c,v=map(int,h().split());G[r][c]=v
F=[[[0]*-~C for i in f(R+1)]for i in f(4)]
for r in f(1,R+1):
	for x in f(1,4):
		for c in f(1,C+1):F[x][r][c]=g(F[x-1][r][c],F[x-1][r][c-1]+G[r][c],F[x][r][c-1],(x<2)*(G[r][c]+g(F[1][r-1][c],F[2][r-1][c],F[3][r-1][c])))
print(F[3][R][C])