(R,C,K),*RCV = $<.map{|ln| ln.split.map(&:to_i) }

Rs = Array.new(R){ [0]*C }
RCV.each{|s,d,v|
	Rs[s-1][d-1] = v
}

r0 = [0]*C
while r1 = Rs.shift
	c,vs = 0,[0]*4
	while c < C
		if vs[0] < r0[c]
			vs[0] = r0[c]
			if vs[1] < vs[0]
				vs[1] = vs[0]
				if vs[2] < vs[1]
					vs[2] = vs[1]
					if vs[3] < vs[2]
						vs[3] = vs[2]
					end
				end
			end
		end
		if 0 < v = r1[c]
			vs[3] = vs[2]+v if vs[3] < vs[2]+v
			vs[2] = vs[1]+v if vs[2] < vs[1]+v
			vs[1] = vs[0]+v if vs[1] < vs[0]+v
		end
		r0[c] = vs[-1]
		c += 1
	end
end

p r0[-1]
