#include <iostream>
using namespace std;
typedef long long Int;

Int H, W, K, h, w, v;
Int dp[5500][5500][4], fld[5500][5500];

int main() {
  cin >> H >> W >> K;
  for (int _ = 0; _ < K; _++) {
    cin >> h >> w >> v;
    fld[h - 1][w - 1] = v;
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      Int v = fld[i - 1][j - 1];
      for (int k = 0; k < 4; k++) {
        dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][k]);
        if (0 < i) {
          dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][k] + v);
        }
        dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]);
        if (0 < k - 1) {
          dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + v);
        }
      }
    }
  }

  Int ans = 0;
  for (int i = 0; i < 4; i++) {
    ans = max(ans, dp[H][W][i]);
  }
  cout << ans << endl;
  return 0;
}