Kunai is an acuate weapon used by ninjas whose shape is similar to a knife. Ninjas were attacking their enemies by throwing kunais against them.
There are ninjas in a grid of squares with columns and rows. Every ninja is in the center of a square, and no two ninjas share the same square. Each ninja has a kunai, and looks toward one of the four directions; up, down, left, or right. At time , every ninja threw his/her kunai to the direction he/she is looking toward.
Every kunai proceeds straight with speed . If more than one kunai comes to the same place at the same time, they clash with each other and disappear. The size of a kunai is so small that we can ignore it. Also, since ninjas can move quickly, they will not be hit by kunais. Each kunai continues to proceed along its direction without losing its speed unless it is clashed with another kunai.
In the following figures, the arrows represent kunais. The direction of an arrow describes the direction of a kunai. In these figures, all thick arrows will clash.

On the other hand, in each of the following figures, a thick arrow will not clash with another thick arrow. In the second and the third figure, a thin arrow clashes with a thick arrow. Because clashed arrows will disappear, a thick arrow will not clash with another thick arrow in each of these figures.

Task
Count the number of squares in the w \times h grid where kunais pass through after a sufficient amount of time passed.
Constraints
1 \leq n \leq 100000 - The number of ninjas
1 \leq w \leq 1000000000, 1 \leq h \leq 1000000000 - The size of the grid
1 \leq x_i \leq w, 1 \leq y_i \leq h - The coordinates of ninjas
The first line contains two space separated integers , , which describe the size of the grid. The second line of input contains an integer , the number of ninjas. The -th line (1 \leq i \leq n) of the following lines contains three space separated integers x_i, y_i, d_i, describing that the position of the ninja is in the x_i-th column from left and y_i-th row from above. No two ninjas share the same position. The direction of the ninja is described by the value of d_i.
When d_i = 0, the ninja is looking toward the right.
When d_i = 1, the ninja is looking upward.
When d_i = 2, the ninja is looking toward the left.
When d_i = 3, the ninja is looking downward.
Output the number of squares in the w \times h grid where kunais pass through after a sufficient amount of time passed.
Example 1
Example 1
In this example, the grid at time is described as follows.

The kunai thrown by the ninja is denoted by the kunai . At time , the kunai and the kunai will clash each other and disappear. The following figure describes the grid at time . Here gray squares denote the squares where kunais already passed through.

At time , the kunai and the kunai will clash each other and disappear. The grid at time is described as follows.

No more kunais are clashed in a square after time . The grid after a sufficient amount of time passed is described as follows.

Finally, the number of squares in the grid where kunais pass through is . Therefore, we should output .