ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1599. Winding Number

Time limit: 1.0 second
Memory limit: 64 MB
You have just completed the construction of your model railway. The railway is made in a form of a closed route, the tracks may intersect and overlap one another in different levels. You're standing at some point and follow the locomotive with your eyes. Once the locomotive completes a full circle you want to say how many full turns around your axis you made.

Input

The first line contains the integer n (3 ≤ n ≤ 5000). Each of the next n lines contains a point with integer coordinates (up to 109 by absolute value) that represents the track joint. The tracks are straight segments between successive points in this list. The last joint is connected to the first one with one more track.
The next line contains the integer m (1 ≤ m ≤ 5000). Each of the next m lines contains a point with integer coordinates (up to 109 by absolute value) that represents a standing point.

Output

For each standing point output “EDGE” if you stand on one of the tracks. Otherwise, output the number of full turns in positive direction.

Sample

inputoutput
8
-2 -2
-5 1
-2 4
1 3
-2 0
-3 1
-2 2
1 1
3
-2 1
0 0
1 2
-2
EDGE
0
Problem Author: Vladimir Yakovlev