#include<bits/stdc++.h>
using namespace std;
long long r,c,k,x,y,v,ans;
long long m[3005][3005],f[3005][3005][5];
int main()
{
	cin>>r>>c>>k;
	for(int i=1;i<=k;++i)
	{
		cin>>x>>y>>v;
		m[x][y]=v;
	}
	for(int i=1;i<=r;++i)
	 for(int j=1;j<=c;++j)
	  for(int k=1;k<=3;++k)
	   f[i][j][k]=max(f[i-1][j][3]+m[i][j],max(f[i][j-1][k-1]+m[i][j],f[i][j-1][k])),
	   ans=max(ans,f[i][j][k]);
	cout<<ans;
	return 0;
}