We have paper divided into MxN square cells, black and white.
Black cells form joined figure (two cells are adjacent if their intersection is segment).

The description of the black figure is given as union of 1 x L (y-strip) and L x 1 (x-strip) tiles.

Strips can intersect and overlap, but two strips can not start at one cell.
Starting cell of a strip is the cell with minimum rating.
Cell rating is defined as x*N+y. Coordinates x and y are integers from
sets 1..M and 1..N.

Write a program that answers

Question 1. What is the number of white cells?

Question 2. What is the number of joined white figures?

Each strip can be described by four numbers:

1) direction, D, that is 0 or 1: 0 — x-strip, 1 — y-strip;

2-3) coordinates of the starting cell, (X, Y);

4) strip length, L.

Strips are given in the order of starting cells.

Number of strips is less than 256000.

Input

The first line contains number P equal to 1 or 2.
The second line contains M and N, 1 ≤ M ≤ 4000, 1 ≤ N ≤ 4000.
Then number K follows, 0 ≤ K ≤ 256000, equal to number of strips.
Then K lines, each with 4 numbers DXYL, follow.

Output
If P == 1 then output answer to the question 1.