Irregular Cakes (Small)

Split the region between two polylines into G equal areas with vertical cuts and print each cut position.

Medium5Binary searchGeometryNo attempts yetTime limit5sMemory limit512 MB

Problem

Mary the mathematician opened a bakery a few years ago. She is tired of baking the same rectangular and circular cakes, so for her next birthday she wants to bake an irregular cake, defined as the region between two polylines from x=0x = 0 to x=Wx = W. The two polylines are called the lower boundary and the upper boundary.

A polyline is defined by a sequence of points (P0,P1,,Pn)(P_0, P_1, \dots, P_n) listed from left to right. Joining consecutive points with line segments produces the polyline.

Today is Mary's birthday and she has baked an irregular cake bounded by a lower boundary with LL points and an upper boundary with UU points. After singing "Happy Birthday", she wants to make G1G - 1 vertical cuts that split the cake into GG slices of equal area, one for every guest. The irregular shape makes the cut positions hard to find. Compute where she has to cut.

Input

The first line contains the number of test cases TT. TT test cases follow.

The first line of each test case contains four integers separated by spaces: WW (the width of the cake), LL (the number of points on the lower boundary), UU (the number of points on the upper boundary) and GG (the number of guests).

The next LL lines describe the lower boundary. The ii-th of those lines contains the coordinates xix_i and yiy_i of the ii-th point of the lower boundary. The next UU lines describe the upper boundary in the same format.

Limits

  • 1T1001 \le T \le 100
  • 1W10001 \le W \le 1000
  • 2L1002 \le L \le 100
  • 2U1002 \le U \le 100
  • Every coordinate is an integer between 1000-1000 and 10001000, inclusive.
  • The leftmost point of each boundary has xx coordinate 00.
  • The rightmost point of each boundary has xx coordinate WW.
  • The points of one boundary are given in increasing order of xx coordinate and their xx coordinates are distinct.
  • The lower boundary is strictly below the upper boundary for every xx between 00 and WW, inclusive. That is, at every xx position the yy coordinate of the lower boundary is smaller than the yy coordinate of the upper boundary.
  • 2G32 \le G \le 3

Output

For each test case, print GG lines. The first line is Case #x:, where x is the test case number starting from 1. The next G1G - 1 lines contain the xx coordinates of the cuts, one per line, ordered from the leftmost cut to the rightmost cut.

The height of the cake is positive everywhere, so the area measured from the left edge increases strictly with xx and each cut position is unique.

Print each coordinate with exactly six digits after the decimal point, rounding the seventh digit half up. If the answer is 55, print 5.000000. In every test file the exact answer is at least 10710^{-7} away from a value whose rounding would change.