Bisectors
We all probably know how to find equation of bisectors in Coordinate Geometry. If the equations of two lines area_ix + b_iy + c_i = 0 and a_jx + b_jy + c_{j }= 0, then the equations of the bisectors of the four angles they create are given by . Now one has to be quite intelligent to find out for which angles to choose the '+' (plus) sign and for which angles to choose the '-' (minus) sign. You will have to do similar sort of choosing in this problem. Suppose there is a fixed point (C_x, C_y) and there are n (n ≤ 10000) other points around it. No two points from these n points are collinear with (C_x, C_y). If you connect all these point with (C_x, C_y) you will get a star-topology like image made of n lines. The equations of these n lines are also given and only these equations must be used when finding the equation of bisectors. This n lines create n(n-1)/2 acute or obtuse angles in total and so they have total n(n-1)/2 bisectors. You have to find out how many of these bisectors have equations formed using the + sign. The image below shows an image where n = 5, C_{x }= 5 and C_{y }= 2. This image corresponds to the only sample input.
Input
The input file contains maximum 35 sets of inputs. The description of each set is given below:
First line of each set contains three integers C_x, C_y (-10000 ≤ C_x, C_y ≤ 10000) and n (0 ≤ n ≤ 10000). Each of the next n lines contains two integers x_i, y_i (-20000 ≤ x_i, y_i ≤ 20000) and a string of the form a_ix + b_iy + c_{i }= 0. Here (x_i, y_i) is the coordinate of a point around (C_x, C_y) and the string denotes the equation of the line segment formed by connecting (C_x, C_y) and (x_i, y_i). You can assume that (-100000 ≤ a_i, b_i ≤ 100000) and (-2000000000 ≤ c_i ≤2000000000). This equation will actually be used to find the equations of bisectors of the angles that this line creates.
Input is terminated by a set where the value of n is zero.
Output
For each set of input produce one line of output. This line contains an integer number P that denotes of the bisector equations how many are formed using the + sign in the bisector equation .