#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(long long i = (a); i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

ll dp[3001][3001][4];

void solve()
{
ll r,c,k;
cin>>r>>c>>k;
vector<vector<ll>> v(r+1,vector<ll>(c+1,0));
while(k--){
		ll a,b;
		cin>>a>>b;
		ll x;
		cin>>x;
		v[a][b]=x;
}
	

dp[0][0][0]=0;
dp[1][1][0]=0;
for(ll i=1;i<=r;i++){
	dp[i][1][0]=0;
}
for(ll i=1;i<=r;i++){
	for(ll j=1;j<=c;j++)
		{
			for(ll k=1;k<=3;k++){
				dp[i][j][k]=max(dp[i-1][j][3],dp[i][j-1][k]);
			}
			
			for(ll k=1;k<=3;k++){
				dp[i][j][k]=max(dp[i][j][k],max(dp[i-1][j][3]+v[i][j],dp[i][j-1][k-1]+v[i][j]));
			}
			
		}
}

ll temp=0;
temp=dp[r][c][3];

cout<<temp;
}



int main(){
	ll t;
	//cin>>t;
	t=1;
	while(t--){
			solve();
	cout<<endl;
	}



}