Under construction

Still being built. Things may change

Cutting

Time limit0.5sMemory limit1024 MB

Summary
Each request cuts a V-shaped wedge upward from a lattice point, and the task is to print the remaining area after every cut.
Level

Medium6 of 10

Topics
Geometry, Binary search, Implementation
Solved
No attempts yet

Problem

You have a rectangular sheet of paper with dimensions N×MN \times M centimeters. The sheet is divided into a net of 1×11 \times 1 centimeter squares. Treat the sheet as a coordinate system whose origin (0,0)(0,0) is the lower left corner. Each vertex of a square has integer coordinates: between 0 and NN on the x axis and between 0 and MM on the y axis.

You receive a sequence of requests to cut the piece of paper that remains. Each request is a pair of nonnegative integers (p,q)(p, q), a vertex of the net that lies in the uncut portion of the paper. Cutting works as follows. Two segments start at (p,q)(p, q). One is at an angle of 45 degrees to the x axis, and the other is at an angle of 135 degrees. Both point upwards, that is, with increasing y. Both segments end at the border of the sheet. The portion of the paper above the drawn segments is cut off, and the rest remains as the new figure.

One of the segments may have length 0. This happens when the point lies on the leftmost or rightmost border of the rectangle. Each request is guaranteed to cut off a figure with positive area.

Input

The first line contains two positive integers NN and MM, the dimensions of the initial sheet.

The second line contains a positive integer QQ, the number of cutting requests.

Each of the next QQ lines contains two nonnegative integers xx and yy, separated by a space. These are the coordinates of the point that defines a request.

Output

For each request, print the area of the remaining figure on a separate line. Print the area with exactly two digits after the decimal point.

Constraints

1≤N×M≤10121 \le N \times M \le 10^{12}

1≤Q≤1500001 \le Q \le 150000

Examples1

  1. Example 1

    Input
    20 10
    4
    10 5
    4 7
    0 1
    16 3
    
    Expected output
    175.00
    167.00
    138.50
    103.00