#include<bits/stdc++.h>
using namespace std;

using LL = long long;

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

  vector<vector<LL>> V(R+2, vector<LL>(C+2));
  for(auto i=0; i<K; ++i) {
    int r, c, v;
    cin >> r >> c >> v;
    V[r][c] = v;
  }

  vector<vector<vector<LL>>> dp(R+3, vector<vector<LL>>(C+3, vector<LL>(5)));
  dp[1][1][1] = V[1][1];
  for(auto i=1; i<=R; ++i) for(auto j=1; j<=C; ++j) for(auto k=0; k<4; ++k) {
    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]);
    dp[i+1][j][1]   = max(dp[i+1][j][1],   dp[i][j][k] + V[i+1][j]);
    dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + V[i][j+1]);
  }
  cout << max({dp[R][C][0], dp[R][C][1], dp[R][C][2], dp[R][C][3]}) << endl;
}
