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

#define ll long long
#define rep(i,n) for(int i = 0;i < (n); i++)
#define mod 1000000007
#define chmax(x,y) x=max(x,y)
 
//2020/9/16 @ST

int d[3005][3005] = { 0 };
ll dp[3005][3005][4] = { 0 };

int main() {
	int r, c, k;
	cin >> r >> c >> k;
	rep(i, k) {
		int rk, ck, vk;
		cin >> rk >> ck >> vk;
		d[rk - 1][ck - 1] = vk;
	}
	rep(i, r)	rep(j, c) {
		for (int l = 2; l >= 0; l--) {
			chmax(dp[i][j][l + 1], dp[i][j][l] + d[i][j]);
		}
		rep(l, 4) {
			chmax(dp[i + 1][j][0], dp[i][j][l]);
			chmax(dp[i][j + 1][l], dp[i][j][l]);
		}
	}
	ll ans = 0;
	rep(l, 4)chmax(ans, dp[r - 1][c - 1][l]);
	cout << ans << endl;
	return 0;
}