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.
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).
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 |
Instancia 1
Instancia 2 |