The Bus

No attempts yetTime limit3sMemory limit512 MB

Problem

The streets of a city form a regular, chessboard-like grid: every street runs either north-south (an NS-street) or west-east (a WE-street), and each street spans the whole city. Every NS-street intersects every WE-street and vice versa. The NS-streets are numbered from 11 to nn starting from the westernmost, and the WE-streets are numbered from 11 to mm starting from the southernmost. The intersection of the ii-th NS-street with the jj-th WE-street is denoted by the pair (i,j)(i, j) (for 1in1 \le i \le n, 1jm1 \le j \le m).

A bus line uses these intersections as stops. The bus starts at intersection (1,1)(1, 1) and finishes at intersection (n,m)(n, m), and it may move only east and/or north (that is, each move increases the NS-street number or the WE-street number).

Passengers wait at some of the intersections. The driver wants to choose a route that picks up as many passengers as possible (assume the bus is spacious enough to carry everyone it passes, regardless of the route chosen).

Write a program that reads a description of the road network and the number of passengers waiting at each intersection, and outputs the greatest number of passengers the bus can pick up.

Input

The first line contains three positive integers nn, mm and kk - the number of NS-streets, the number of WE-streets, and the number of intersections at which passengers are waiting (1n1091 \le n \le 10^9, 1m1091 \le m \le 10^9, 1k1051 \le k \le 10^5).

Each of the next kk lines describes one intersection with three space-separated positive integers xix_i, yiy_i and pip_i (1xin1 \le x_i \le n, 1yim1 \le y_i \le m, 1pi1061 \le p_i \le 10^6), meaning that pip_i passengers wait at intersection (xi,yi)(x_i, y_i). Each intersection appears at most once in the input. The total number of waiting passengers does not exceed 10910^9.

Output

Output a single line with one integer: the greatest number of passengers the bus can pick up.

Hint