Kingdom Reunion

Kalvin John Ian Helvik IV and Karl James Ingram Helvik III are second cousins and kings of neighbour- ing countries, Aastria and Abstria. One hundred years ago their countries constituted a single country, but the old king Helvik died and left his country to his twin sons, Ian and Ingram. Nobody knew what to do, until it was suggested to split the country into two equal parts. This was an overwhelmingly complex task, which the wisemen tried to cope with by calling the best minds from the future to solve. Unfortunately, five attempts to solve the problem had failed, and the bloody civil war broke out. It lasted for seven years and ended with the NEERC (Northeastern Enormously Ragged Combat). As the Final Ordinance said, there would be two new countries in the place of the old one, one for Ian and one for Ingram. But these two countries had unequal areas, so it took only three years for war to start again. After ninety years of war, all resources of two countries were exhausted. At the end of the year both kings had realized that they would not survive the next year if the war continued, so they simultaneously sent envoys with offers of peace. They had decided to unite their countries back and live in peace. The united land of Aastria and Abstria was named Aabstria. In the manuscripts of the old ages you had found several descriptions of boundaries of the countries. Each description is a sequence of locations of boundary monuments, which are listed in clockwise or counterclockwise order following the boundary. However, you suddenly realized that in different sources locations of boundary monuments differ. In some of them, the boundary does not even form a polygon. You decided to do an investigation to discover what the actual boundaries of the countries were. Given locations of the boundary monuments for each of three countries the following statements should hold: • For each country, the polyline formed by the boundary monuments should be a polygon. A polyline is considered to be a polygon if it has at least three points, no self-intersections, self-touches or holes, and has a non-zero area. • The interiors of Aastria and Abstria polygons should not intersect. • The union of Aastria and Abstria should be precisely equal to Aabstria. Your task is to write a program that checks if these facts are true. Input The input will contain several test cases, each of them as described below. The first line of the input contains the number of vertices in the boundary of Aastria, na (1 ≤ na ≤ 10000). The next na lines contain two integers each — the coordinates of Aastria boundary monuments in clockwise or counterclockwise order. After that, descriptions of Abstria and Aabstria are given in the same format as above. The coordinates of all monuments do not exceed 105 by their absolute values. It is guaranteed that two boundary monuments can coincide only if they belong to different countries. Output For each test case, write to the output as described below. Output a single line with one the following strings (without quotes):

2/4 • if the boundary monuments of Aastria do not form a polygon, output “Aastria is not a polygon”; • otherwise, if the boundary monuments of Abstria do not form a polygon, output “Abstria is not a polygon”; • otherwise, if the boundary monuments of Aabstria do not form a polygon, output “Aabstria is not a polygon”; • otherwise, if interiors of Aastria and Abstria intersect, output “Aastria and Abstria intersect”; • otherwise, if the union of Aastria and Abstria is not equal to Aabstria, output “The union of Aastria and Abstria is not equal to Aabstria”; • otherwise, output “OK”. Images for the samples:

3/4 Sample Input 3 00 20 11 3 00 20 1 -1 4 00 11 20 1 -1 4 00 11 01 10 3 00 01 02 1

4/4 12 3 02 10 22 3 01 21 13 3 00 30 03 3 00 10 01 3 20 30 21 3 40 50 41 Sample Output OK Aastria is not a polygon Aastria and Abstria intersect The union of Aastria and Abstria is not equal to Aabstria