Under construction

Still being built. Things may change

Artifact Excavation

Interview

Time limit1sMemory limit1024 MB

Summary
Given the fragment coordinates of each artifact, find the artifact whose bounding rectangle has the largest area, breaking ties by smallest number.
Level

Easy3 of 10

Topics
Array, Implementation
Solved
No attempts yet

Problem

The Hongik University playground is a grid with RR rows and CC columns. Fragments of artifacts that could shake up the academic world have been found on this playground.

Only one artifact can be excavated at a time. So the artifact with the largest expected size is excavated first. If several artifacts share the largest expected size, the one with the smallest number is excavated first.

Each fragment is 1×11 \times 1 in size, and several fragments can be at the same position. The expected size of an artifact is the size of the smallest rectangle that encloses all of its fragments. All sides of the rectangle must be parallel to the sides of the playground.

Input

The first line contains two integers RR and CC, separated by a space. (1≤R,C≤100 000)(1 \leq R, C \leq 100\,000)

The second line contains the number of fragments NN. (1≤N≤100 000)(1 \leq N \leq 100\,000)

From the third line, the next NN lines each contain three integers aia_i, viv_i, and hih_i, separated by spaces. (1≤ai≤N;(1 \leq a_i \leq N; 1≤vi≤R;1 \leq v_i \leq R; 1≤hi≤C)1 \leq h_i \leq C) This means that a fragment of artifact aia_i is at row viv_i, column hih_i.

Output

Print the number of the artifact that is excavated first and its expected size, separated by a space.

Examples1

  1. Example 1

    Input
    5 4
    6
    1 2 4
    4 3 4
    5 2 4
    1 5 3
    2 3 3
    4 1 1
    
    Expected output
    4 12