#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int r, c, k;
int grid[3005][3005];
int dp[3005][3005][4]; //row col taken

int compute(int i,int j,int taken){
    if(i>r || j>c)return 0;
    int &ans=dp[i][j][taken];
    if(ans!=-1)return ans;
    if(taken>=3){
        ans=max(compute(i+1,j,0),compute(i,j+1,taken));
    }
    else{
        ans=max({compute(i+1,j,0)+grid[i][j],compute(i,j+1,taken+1)+grid[i][j],compute(i,j+1,taken)});
    }
    return ans;
}
int32_t main() {

    fast
    cin >> r >> c >> k;
    int x, y, value;

    for(int i = 0; i < k; i++) {
        cin >> x >> y >> value;
        grid[x][y] = value;
    }
    memset(dp,-1,sizeof dp);
    int ans=compute(0,0,0);
    cout << ans<< endl;




    return 0;
}

