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


ll dp[3005][3005][4];
int A[3005][3005];

int main() {
  int R,C,K;
  cin >> R >> C >> K;

  rep(i,K) {
    int r,c,v;
    cin >> r >> c >> v;
    r--;
    c--;
    A[r][c]= v;
  }

  rep(i,R) rep(j,C) {
    if(i > 0) {
      rep(k,4){
        chmax(dp[i][j][0], dp[i-1][j][k]);
      }
    }
    if(j > 0){
      rep(k,4){
        chmax(dp[i][j][k], dp[i][j-1][k]);
      }
    }
    int v = A[i][j];
    if (v > 0) {
      for(int k=3; k>0; k--){
        chmax(dp[i][j][k], dp[i][j][k-1] + v);
      }
    }
  }
  
  ll ans = 0;
  rep(k,4){
    chmax(ans, dp[R-1][C-1][k]);
  }
  cout << ans << endl;
  return 0;
}
