Amy crashed onto a distant planet and broke her starship's window. Luckily, she explored the planet and discovered a new gem called Topium. Because of its many special properties, she wants to use it to create a new window.
Amy needs her ship to withstand the high temperature inside stars. After doing some experiments, she noticed that the gem consists of many small crystals arranged in a flat grid lattice with
To create her window, Amy will need to cut out a rectangular plate with
Input Specification
The first line contains
The second line contains
The third line contains
The next
Output Specification
Output the maximum melting point of a rectangle with
Constraints
Subtask 1 [10%]
Sample Input 1
1 1
5 5
6
1 1 10
2 2 5
3 2 8
2 3 3
4 4 -1
5 5 12
Sample Output 1
12
Explanation
The
Sample Input 2
2 2
10 10
6
1 1 10
2 2 5
3 2 8
2 3 3
4 4 -1
5 5 12
Sample Output 2
16
Sample Input 3
1 1
10 10
6
1 1 -10
2 2 -5
3 2 -8
2 3 -3
4 4 -1
5 5 -12
Sample Output 3
0
Comments
Note:
In this problem
indexes into rows, while 
indexes into columns.