Meteor
Time limit1sMemory limit128 MB
The task counts the largest number of meteors strictly inside a fixed rectangle at one moment as each meteor moves along a straight path.
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 meteors, each in uniform linear motion. Meteor is at position at time , where is a non-negative real number, is its starting point, and is its non-zero velocity vector. For example, if and , then at the meteor is at .
The telescope frame is an axis-aligned rectangle whose lower-left corner is and whose upper-right corner is . 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
Input
The input is read from standard input and contains test cases. The first line holds the integer . Each test case is:
- One line with two integers and (), the width and height of the telescope frame, separated by a single space.
- One line with the integer (), the number of meteors.
- lines, each with four integers , , , and separated by single spaces, where is the starting point and is the non-zero velocity vector . Here and , and at least one of and is nonzero. All starting points 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.