Meteor

No attempts yetTime limit1sMemory limit128 MB

Problem

A well-known internet company runs a web photo service that lets users control a high-performance telescope and photograph events in the sky. A record-breaking meteor shower is coming, and the company is holding a contest: whoever captures a single photo containing the most meteors wins. The trajectory of every meteor is published in advance, so the winning move is to compute the exact moment when the telescope frame holds the largest number of meteors.

There are nn meteors, each in uniform linear motion. Meteor mim_i is at position pi+tvip_i + t \cdot v_i at time tt, where tt is a non-negative real number, pi=(xi,yi)p_i = (x_i, y_i) is its starting point, and vi=(ai,bi)v_i = (a_i, b_i) is its non-zero velocity vector. For example, if pi=(1,3)p_i = (1, 3) and vi=(2,5)v_i = (-2, 5), then at t=0.5t = 0.5 the meteor is at (1,3)+0.5(2,5)=(0,5.5)(1, 3) + 0.5 \cdot (-2, 5) = (0, 5.5).

The telescope frame is an axis-aligned rectangle whose lower-left corner is (0,0)(0, 0) and whose upper-right corner is (w,h)(w, h). A meteor counts as being in the frame only when it is strictly in the interior, never on the boundary. In Figure 1, for instance, some starting points never enter the interior at all and so can never be photographed. Compute a time at which the number of meteors inside the frame is as large as possible, and output that maximum count.

Figure 1

Figure 1

Input

The input is read from standard input and contains TT test cases. The first line holds the integer TT. Each test case is:

  • One line with two integers ww and hh (1w,h1000001 \le w, h \le 100000), the width and height of the telescope frame, separated by a single space.
  • One line with the integer nn (1n1000001 \le n \le 100000), the number of meteors.
  • nn lines, each with four integers xix_i, yiy_i, aia_i, and bib_i separated by single spaces, where (xi,yi)(x_i, y_i) is the starting point pip_i and (ai,bi)(a_i, b_i) is the non-zero velocity vector viv_i. Here 200000xi,yi200000-200000 \le x_i, y_i \le 200000 and 10ai,bi10-10 \le a_i, b_i \le 10, and at least one of aia_i and bib_i is nonzero. All starting points pip_i are distinct.

Output

Write to standard output. For each test case, print on its own line the maximum number of meteors that can be inside the telescope frame at a single moment.