A Cut Rectangle#4780

A Cut Rectangle

1 second
64 megabytes
Easy

On a plane, a rectangle is drawn and then divided using straight lines. Write a program to calculate how many of the resulting sections of the rectangle are triangular.

The image corresponds to the first example of input and output data.

Input

First, two positive numbers, and , are provided, representing the coordinates of the top right corner of the rectangle. The rectangle is positioned in a coordinate system such that its bottom left corner is at coordinates , with its sides parallel to the coordinate axes.

Next, an integer is given, indicating the number of cuts (1 \leq N \leq 200). Each cut is described by a straight line. Each line is defined by three numbers , , and , such that all points on this line satisfy the equation A x + B y + C = 0 (where A^2 + B^2 > 0 is always true).

All numbers entered (except ) are real, given with two decimal places, and do not exceed 10^4. No two lines coincide, and none of them align with the sides of the rectangle. Each cut passes through points inside the given rectangle.

Output

Output a single integer, which is the number of sections of the rectangle that are triangular.

Examples

Example 1

Loading
Loading