#Lutece0516. Cake Cutting

Cake Cutting

Migrated from Lutece 516 Cake Cutting

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Today is Simon's birthday, he receives a birthday cake. This cake is a rectangle with its length is NN and width is MM, And Simon cut KK times. Now, he want you to tell him this cake has been divided into how many parts, and the area of each part.

To simplify this problem, we put this cake on a 22-Dimension rectangular coordinate system, and the edge of cake is parallel to the axes. And the lower left corner is at (0,0)(0,0), the upper right corner is at (N,M)(N,M). Each time of cutting will be parallel to the axis, the starting point and the ending point will be integral points.

P.S. We call a point (X,Y)(X,Y) as a integral point if and only if XX and YY are both integers.

Input

First line of the input is a single integer TT(T30T\leq 30), indicates there are TT test cases.

For each test case, the first line is three integers NN(1N5001\leq N\leq 500), MM(1M5001\leq M\leq 500) and KK(1K10001\leq K\leq 1000), the length and the width of the cake, how many times Simon has cut.

Then KK lines followed, the ithi_{th} line contains four integers sx,sy,ex,eys_x,s_y,e_x,e_y(109<sx,sy,ex,ey109-10^9<s_x,s_y,e_x,e_y\leq 10^9), means the start point and the end point, data will ensure that sx=exs_x=e_x or sy=eys_y=e_y. Notice that the starting point or the ending point will not necessary on the cake exactly.

Output

For each case, you should output two lines.

First line,Case #k: n, where kk indicates the case number between 11 and TT, nn means the cake has been divided into how many parts.

Second line should contain nn integers a1,a2,,an1,ana_1,a_2,\cdots ,a_{n-1},a_n, where aia_i means the ithi_{th} part's area, and aiai+1a_i\leq a_{i+1} for 1in11\leq i\leq n-1.

Samples

3
2 2 2
0 1 2 1
1 0 1 2
2 2 2
0 1 2 1
1 0 1 1
2 2 1
1 -3 1 1
Case #1: 4
1 1 1 1
Case #2: 3
1 1 2
Case #3: 1
4

Resources

elfness