Speed Skills

No attempts yetTime limit3sMemory limit256 MB

Problem

Anna just got a new car and wants to take it out on the highway. To lower her chance of getting a speeding ticket, she does not want to drive much faster than anyone else on the highway. She also does not want to drive too slowly, no matter how slowly the other drivers go. So she settled on this strategy. Every time she passes a car, she drops her speed to the average of her old speed and that car's speed. When a car passes her, she raises her speed the same way.

To carry out the strategy she built a small gizmo that checks for passing or passed cars 4 times each second. At every check it sets her car's speed to the average of her current speed and the speeds of all cars she is passing or that are passing her at that instant, rounding the average down to the nearest integer. For example, if at some quarter second Anna is going 6060, is being passed by a car going 6565, and is also passing another car going 5959, her car changes its speed to (60+65+59)/3=61\lfloor (60 + 65 + 59) / 3 \rfloor = 61.

For this problem, Anna is passing a car or being passed by it if the front of the other car is anywhere between the back and the front of Anna's car, inclusive. All cars have the same length, and locations and distances are measured in car lengths, so each car is 11 long. Every car except Anna's travels at a constant speed. Anna's car changes speed instantaneously.

Input

The input holds several test cases.

The first line of each test case has four non-negative integers ll, ss, dd, nn. ll is Anna's current location on the highway (in car lengths), ss is her current speed (in car lengths per second), dd is the location of a destination point on the highway with l<d100000000l < d \le 100000000, and nn is the number of other vehicles on the road, all going in Anna's direction. The maximum value of nn is 100100.

The next nn lines each hold a pair of integers lil_i sis_i (1in)(1 \le i \le n), the location and the speed of the ii-th vehicle. Every location refers to the front of the car in question and is at most 100000000100000000. All input refers to locations and speeds at time t=0t = 0, which is also the time Anna's gizmo takes its first reading.

A line containing four 00's terminates the input. Do not process that line.

Every test case guarantees that Anna reaches the destination.

Output

For each test case print one line with the time Anna reaches the destination point (in seconds) and her speed at that time (in car lengths per second). The destination point is reached the moment the front of Anna's car touches it. If her arrival time falls exactly on a quarter second and she is passing or being passed at that same instant, print her new averaged speed.

Use this format for test case kk.

Case k: Anna reaches her destination at time T at a speed of S

TT is the arrival time rounded to the nearest ten-thousandth, always written with four digits after the decimal point. SS is the speed, printed as an integer.