#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define repb(i,n,b) for (ll i = b; i < (ll)(n); i++)
#define rep(i,n) repb(i,n,0)
ll dp[3001][3001][4];
ll gds[3001][3001];
int main(){
	ll R,C,K;
	cin>>R>>C>>K;
	rep(i,K){
		ll r,c,v;
		cin>>r>>c>>v;
		gds[r-1][c-1]=v;
	}
	rep(i,3){
		dp[0][0][i]=gds[0][0];
	}
	dp[0][0][3]=0;
	repb(c,C,1){
		rep(i,3){
			dp[0][c][i]=max(dp[0][c-1][i+1]+gds[0][c],dp[0][c-1][i]);
		}
		dp[0][c][3]=dp[0][c-1][3];
	}
	repb(r,R,1){
		rep(i,3){
			dp[r][0][i]=gds[r][0]+dp[r-1][0][0];
		}
		dp[r][0][3]=dp[r-1][0][0];
	}
	repb(r,R,1){
		repb(c,C,1){
			rep(i,3){
				dp[r][c][i]=max(max(dp[r][c-1][i+1]+gds[r][c],dp[r][c-1][i]),dp[r-1][c][0]+gds[r][c]);
			}
			dp[r][c][3]=max(dp[r][c-1][3],dp[r-1][c][0]);
		}
	}
	cout<<dp[R-1][C-1][0]<<endl;
}
