#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;

int Item[3005][3005];
ll DP[3005][3005][4];

int main(){
    int R,C,k;cin>>R>>C>>k;
    rep(i,k){
        int r,c,v;
        scanf("%d %d %d",&r,&c,&v);
        r--;c--;
        Item[r][c]=v;
    }
    rep(i,R)rep(j,C){
        for(int k=2;k>=0;k--){
            DP[i][j][k+1]=max(DP[i][j][k+1],DP[i][j][k]+Item[i][j]);
        }
        rep(k,4){
            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]);
        }
    }

    ll ans=0;
    rep(k,4)ans=max(ans,DP[R-1][C-1][k]);
    cout<<ans<<endl;
}