#include "bits/stdc++.h"

using namespace std;
using ll = long long;

const int mx = 3000 + 9;

int R, C, K;
ll g[mx][mx];
ll dp[mx][mx][4];

ll solve(int i, int j, int k) {
    if (i > R) return 0;
    if (j > C) return 0;
    ll& ans = dp[i][j][k];
    if (ans != -1) return ans;

    ans = 0;
    if (k > 0) {
        ans = max(ans, g[i][j] + solve(i, j + 1, k - 1));
        ans = max(ans, g[i][j] + solve(i + 1, j, 3));
    }

    ans = max(ans, solve(i, j + 1, k));
    ans = max(ans, solve(i + 1, j, 3));
    
    return ans;
}

int main() {
    scanf("%d %d %d", &R, &C, &K);
    for (int i = 0; i < K; i++) {
        int r, c; ll v;
        scanf("%d %d %lld", &r, &c, &v);
        g[r][c] = v;
    }

    memset(dp, -1, sizeof dp);
    ll ans = solve(1, 1, 3);
    printf("%lld\n", ans);
}