提示: 欢迎访问OurACM平台。
Problem 1120 A Pilot in Danger!

Accept: 247    Submit: 569
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

The World War II was going on in 1941. Germany, Italy and Hungary had occupied Yugoslavia for months. Led by Tito, though having losing thousands of lives and still being under the threat of Fascist, Yugoslav were fighting against the enemy toughly until the enemy escaped from their motherland. On the east, although on August 23rd, 1939 Germany and Soviet Union signed a treaty that they wouldn’t invade each other, Hitler attacked Soviet Union without declare on June 22nd, 1941. The war came into more and more impetuous. On October 2nd, Germany began to attack Moscow, trying to occupy it in ten days. However, Moscow still alive after two months, as sacrificing thousands of people! Then, after Moscow Defense and Stalingrad Defense, Soviet Union counterattacked Germany.

One day, the oil of a Soviet bomber on task run down, and the pilot had to bail out in the enemy region. He was in danger! He became calm quickly, and he must know whether he’s in enemy’s barrack, for he was not afraid of any enemy out of their barrack. If unfortunately he’s, he must get the secret number, which allowed anyone pass the watch without trouble.

The barrack was an area bounded by a fence on some flat field. In the plane projection the fence has a form of a closed polygonal line (without self-intersections), which was specified by Cartesian coordinates (xi, yi) of its n vertices. The pilot stood on the field at the point with coordinates (0, 0). The pilot may be located either outside or inside the fence, but not on its sides.

How to get the secret number of the barrack? There are two different primes p, q, p≠q, in the barrack, as everybody could get it with ease. The secret number indicated that how many positive integers that can not be in the form of px+qy while x, y are integers and x, y>=0.

For example, given p=3 and q=5, there are four positive integers, 1, 2, 4, 7, which can not be in the form mentioned above. So, the secret number was 4.

Your task: Decide whether the pilot was in the barrack. If he was, get the secret number.

Input

The input file consists with several tests. For every test, first line contains a single integer n, fitting 3<=n<=16, and while n=0 means the end of the input. n is the number of the vertices of the fence. Then n files follow, every line contains two real numbers xi and yi, separated by space(s). After that, there are two different primes p, q, 2<=p, q<=1000, in the next line, which help you to get the secret number as above.

The vertices may appear clockwise or counterclockwise.

Output

For every test, first output the number of the pilot. Next line tell us whether the pilot was in danger (if he's in the enemy's barrack) or not. If he was, tell us the secret number in the next line.
Write an empty line after every test.

Sample Input

4 -1.0 -1.0 2.0 -1.0 2.0 2.0 -1.0 2.0 3 5 5 -2.5 -2.5 10.5 -2.5 10.5 -1.5 -1.5 -1.5 -2.5 20.5 2 7 0

Sample Output

Pilot 1 The pilot is in danger! The secret number is 4. Pilot 2 The pilot is safe.

Source

THU 2000

Submit  Back  Status  Discuss