#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

ll dp[3003][3003][4];
ll gs[3003][3003];
int main() {
  int r, c, k, y, x, v;
  cin >> r >> c >> k;

  rep(i, 0, k) {
    cin >> y >> x >> v;
    --y, --x;
    gs[y][x] = v;
  }

  rep(i, 0, r) rep(j, 0, c) rep(a, 0, 4) {
    if (a + 1 < 4) {
      dp[i][j + 1][a + 1] = max(dp[i][j + 1][a + 1], dp[i][j][a] + gs[i][j]);
      dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][a] + gs[i][j]);
    }
    dp[i][j + 1][a] = max(dp[i][j + 1][a], dp[i][j][a]);
    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][a]);
  }

  ll ans = 0;
  rep(a, 0, 4) {
    ans = max(ans, dp[r][c - 1][a]);
    ans = max(ans, dp[r - 1][c][a]);
  }
  cout << ans << '\n';

  return 0;
}