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