Bacterial colony#558

Bacterial colony

1 second
64 megabytes
Very easy

Add seven times, measure once,

So how many bacteria live here,

With a ruler or a protractor.

Well, how many? Five or still four?

Advice from the professor to the young lab assistant

In a top-secret bacteriological laboratory, scientists have developed a new type of bacteria. To study their behavior under various conditions, they created a special rectangular grid of size M \times N, made up of individual cells. Each cell is identified by two coordinates: the row number, ranging from to , and the column number, ranging from to . Initially, all cells in the grid are empty, containing no bacteria. Scientists then populate the grid by repeatedly performing the following operation: they select a specific row or column and add a certain number of bacteria to each cell in that row or column. The conditions in the grid cells are such that bacteria neither die nor reproduce.

Write a program to determine the cell that contains the largest number of bacteria after all operations are completed.

Input

The first line contains two integers and (1 \le M, N \le 10000), which specify the dimensions of the grid. The second line contains an integer (0 \le L \le 100000), representing the number of settlement operations. Each of the next lines describes one settlement operation and contains three integers , , , where (0 \le k \le 10000) is the number of bacteria added to each cell of the -th row (if b = 1) or the -th column (if b = 2).

Output

Output three integers: the number of bacteria in the most populated cell, along with its coordinates (row number and column number). If multiple cells contain the maximum number of bacteria, you may output the coordinates of any one of them.

Examples

Example 1

Loading
Loading