beecrowd | 1446

Venn Diagram?

Maratona de Programacao IME-USP Brasil
Timelimit: 1

Mickayil was in school studying set theory. Schools in Prague are quite severe. The teacher taught the students how to draw Venn diagrams to three sets, and asked the students to work with diagrams. To impress the teacher with nicely drawn diagrams, Mickayil decided that he would make colorful diagrams. To achieve this goal, he cut out three convex figures using thin colored papers. Mickayil realized that, by overlapping pictures, the intersections could generate new colors.

Thus, we have three convex pictures over a plain surface, each picture with a color. When pictures are overlapped, the color we see is a mixture of the pictures' colors. We can represent the colors by integers between 0 and 15. The mix of colors is done by summing the values of the corresponding colors modulo 16. We want to know what we see when looking at the Mickayil's Venn Diagram, i.e., what colors and their frequences. We will measure this by the visible area of each color.

Input

Several instances are given. Each instance consists of three figures. These figures are given one per line, in the format

ni ci xi1 yi1 xi2 yi2 ... xij yij ... xin yin

for i = 1, 2, 3, where 0 ≤ ni ≤ 200 is the number of points in ith picture's border, ci is the ith picture's color and the pairs (xij , yij) represent i's border's points counterclockwise, given by integers. The input ends when n1 = 0 (note that this instance should not be processed).

Output

You should print a header indicating the number of the instance that is being treated  (Instancia h) and in the following lines the color pair and the total visible area of that color. These lines should be sorted by areas, in a decreasing order. In case of draws, print the increasing order of color. In order to simplify the presentation, show the values of the areas rounded to two decimal places. You must print a blank line after each Instance.

 Sample Input Sample Output 4 5 -1 -1 1 -1 1 1 -1 1 4 13 0 0 2 0 2 2 0 2 3 7 3 0 4 0 4 1 4 1 0 1 3 1 3 4 0 4 4 2 2 2 5 2 5 5 2 5 4 8 1 0 4 0 4 3 1 3 0 Instancia 1 5 3.00 13 3.00 2 1.00 7 0.50 Instancia 2 2 6.00 1 4.00 8 4.00 9 3.00 3 1.00 10 1.00 11 1.00