#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(void){
  int R,C,K; cin>>R>>C>>K;
  vector<vector<ll>> rcv(R+1,vector<ll>(C+1,0));
  for(int i=0; i<K; ++i){ int r,c; cin>>r>>c; cin>>rcv[r][c];}
  vector<vector<vector<ll>>> dp(R+2,vector<vector<ll>>(C+2,vector<ll>(4,0)));
  for(int i=1; i<=R; ++i) for(int j=1; j<=C; ++j){
    for(int k=3; k>0; --k) dp[i][j][k]=max(dp[i][j][k],dp[i][j][k-1]+rcv[i][j]);
    for(int k=0; k<4; ++k){
      dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
      dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
    }
  }
  cout<<dp[R+1][C][0];
  return 0;
}
