Chessfield
Pani Annochka recently got an interview with an IT company. In this interview, she was given a very interesting task:
The girl is given a field divided into squares. That is, each side is . And each square is painted in either white or black.
We say that a chessfield has sizes and , when it consists of rectangles having units in height and units in width. Also, all these rectangles should be painted either white or black. And each white rectangle borders only on black and vice versa — each black borders only on white.
For example, the following chessboard has sizes and (blue is the coordinate axis):
But these are not:
As you may have noticed, there are often a lot of chessfiels with sizes and . The challenge is to say how many there are. No-no-no, it's too easy.
Annochka also knows squares on this field and their colors. Pani must find the number of chessfields with sizes and such that the squares with the corresponding coordinates have the specified colors. Help her do it!
More formally, you are given triplets of numbers: , where () — the coordinates of the lower left edge of the square, and is if this square is to be is painted black, and is if this square is to be painted white. You need to print the number of different chessfields with sizes and that fit under these constraints. Two chessfields are considered different if there is at least one square painted in different colors on these planes.
Input
The first line contains four integers , , , (, , ) — the height of each rectangular, the width of each rectangular, the number of known squares and the number of group.
Each of the next lines contains three integers , , () — the coordinates and color size. Note that coordinates can be repeated.
Output
Print one integer — the number of different chess planes with sizes and that fit the given constraints.
Examples
Note
On the left is an image of a single plane that fits the example limit.
On the right side there is one of the possible chessfields that satisfy the conditions of the example .
(Blue is the coordinate axis, light gray — squares, which should be white, dark gray — squares, which should be black).
Scoring
( points): ;
( points): ;
( points): ;
( points): without additional restrictions.