#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;



void solve(){

    int R,C,K;
    cin >> R >> C >> K;
    
    int f[3001][3001] = {};
    
    rep(i,K){
        int ri,ci,vi;
        cin >> ri >> ci >> vi;
        ri--; ci--;
        f[ri][ci] = vi;
    }
    

    vector<vector<vector<ll>>> dp(R,vector<vector<ll>>(C,vector<ll>(4,0)));
    
    vector<int> dx = {0,1};
    vector<int> dy = {1,0};
    if (f[0][0]){
        dp[0][0][1] = f[0][0];
    }
    
    
    for(int i = 0; i < R; i++){
        for(int j = 0; j < C; j++){
            for(int k = 0; k < 4; k++){
                rep(ii,2){
                    int ni = i + dx[ii];
                    int nj = j + dy[ii];
                    if (ni >= R || nj >= C) continue;
                    if (dx[ii] == 0){
                        rep(b,2){
                            int nk = k;
                            if (b){
                                if (f[ni][nj]) nk = k + 1;
                                if (nk > 3) continue;
                                dp[ni][nj][nk] = max(dp[ni][nj][nk],dp[i][j][k] + f[ni][nj]);
                            }
                            else{
                                dp[ni][nj][nk] = max(dp[ni][nj][nk],dp[i][j][k]);
                            }
                        }
                    }
                    else{
                        for(int nk = 0; nk < 4; nk++){
                            rep(b,2){
                                if (b){
                                    if (f[ni][nj]) nk = nk + 1;
                                    if (nk > 3) continue;
                                    dp[ni][nj][nk] = max(dp[ni][nj][nk],dp[i][j][k] + f[ni][nj]);
                                }
                                else{
                                    dp[ni][nj][nk] = max(dp[ni][nj][nk],dp[i][j][k]);
                                }
                            }
                        }
                    }
                    
                }
            }
        }
    }
    
    ll ans = 0LL;
    rep(i,4){
        ans = max(ans,dp[R-1][C-1][i]);
    }
    cout << ans;
}


int main() {
    int T;
    //cin >> T;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}














Measured memory_bytes: 671464