import kotlin.math.*

fun list() = readLine()!!.split(" ").map {it.toInt()}

fun main() {
	val (r,c,k) = list()
	val goods = Array(r) {LongArray(c) {0L}}
	for(i in 1..k) {
		val (r,c,v) = list()
		goods[r-1][c-1] = v.toLong()
	}

	val dp = Array(r) {Array(c) {LongArray(4) {0L}}}

	for(i in 0 until r) {
		for(j in 0 until c) {
			for(k in 0..3) {
				if(i>0)
					dp[i][j][0] = max(dp[i][j][0],dp[i-1][j][k])
				if(j>0)
					dp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k])
			}
			for(k in 3 downTo 1)
				dp[i][j][k] = max(dp[i][j][k],dp[i][j][k-1]+goods[i][j])
		}
	}
	println(dp[r-1][c-1].max())
}
