#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int a[3005][3005];
ll dp[3005][3005][4];
//配列はグローバルで定義した方がいい？
int main(){
    int r,c,k;cin >> r >> c >> k;
    rep(i,k){
        int ri,ci,vi;cin >> ri >> ci >> vi;
        --ri;--ci;
        a[ri][ci] = vi;
    }

    rep(i,r)rep(j,c){
        for(int k = 2;k >= 0;k--){
            chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
        }
        rep(k,4){
            chmax(dp[i+1][j][0],dp[i][j][k]);
            chmax(dp[i][j+1][k],dp[i][j][k]);
        }
    }
    ll ans = 0;
    rep(i,4) ans = max(ans,dp[r-1][c-1][i]);
    cout << ans << endl;
}