Cutting with Lines Ⅰ
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

There is a matrix in the 2D plane, whose vertices labelled as (0,0), (n, 0), (0, m) and (n, m).

333lfy has q segments. The length of the i-th segment is a_i. He wants to place these segments in this 2D plane.

There are following four ways to place the i-th segment:
  • 1 x --- The coordinates of the endpoints of the i-th segment are (x,m) and (x,m - a_i).
  • 2 x --- The coordinates of the endpoints of the i-th segment are and .
  • 3 x --- The coordinates of the endpoints of the i-th segment are and  .
  • 4 x --- The coordinates of the endpoints of the i-th segment are and

After placing all segments, the matrix is divided into several parts by these segments. Now please calculate the area of the largest part.

输入描述:

The first line of the input contains three integers n, m, q  --- The position of the matrix and the number of the segments.The size of the matrix and the number of the segments.

The next The next q lines each line contains three integers, and the i-th line belong to one of the following four types:
        a_i 1 x --- The length of the i-th segment is a_i and the coordinates of the endpoints are (x,m) and (x,m - a_i).
        a_i 2 x --- The length of the i-th segment is a_i and the coordinates of the endpoints are  and .
        a_i 3 x --- The length of the i-th segment is a_i and the coordinates of the endpoints are  and .
        a_i 4 x --- The length of the i-th segment is a_i and the coordinates of the endpoints are  and (n - a_i,x).

输出描述:

Print one integer — the number satisfying the conditions above.
示例1

输入

复制
4 7 5
2 1 1
6 3 6
2 4 3
3 3 2
3 2 2

输出

复制
14

说明

The example is shown in the figure: