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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int r, c, k;
	cin >> r >> c >> k;
	vector<vector<vector<long long>>> dp(r + 1, vector<vector<long long>>(c + 1, vector<long long>(4)));
	vector<vector<long long>> grid(r, vector<long long>(c));
	for (int i = 0; i < k; i++) {
		int a, b, v;
		cin >> a >> b >> v;
		grid[a - 1][b - 1] = v;
	}
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			vector<long long> dp_before = dp[i][j];
			for (int k = 0; k <= 3; 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]);
				if (k < 3) {
					dp[i][j][k + 1] = max(dp[i][j][k + 1], dp_before[k] + grid[i][j]);
				}
			}
		}
	}
	cout << *max_element(dp[r - 1][c - 1].begin(), dp[r - 1][c - 1].end());
}

