Bacterial colony
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 MxN, made up of individual cells. Each cell is identified by two coordinates: the row number, ranging from 1 to M, and the column number, ranging from 1 to N. 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 M and N (1 <= M, N <= 10000), which specify the dimensions of the grid. The second line contains an integer L (0 <= L <= 100000), representing the number of settlement operations. Each of the next L lines describes one settlement operation and contains three integers b, i, k, where k (0 <= k <= 10000) is the number of bacteria added to each cell of the i-th row (if b=1) or the i-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.