QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#11853. Straight Lines 2

الإحصائيات

By the distance from a given straight line to a polygon we mean the smallest distance of any point of the polygon from this straight line (by the polygon we understand both its edges and its interior). The polygon does not need to be convex, it can also have multiple vertices and self-crossings of its boundary.

Write a program which:

  • reads from the standard input the description of the polygon and description of some number of straight lines,
  • for each straight line calculates the distance from that line to the polygon,
  • writes result to the standard output.

Input Format

In the first line of the standard input there are two integers $ n $ and $ m $ (3 ≤ $ n $ ≤ 50 000, 1 ≤ $ m $ ≤ 50 000), separated by a single space and representing the number of sides of the polygon and the number of straight lines to be analyzed. Each of the following $ n $ lines contains two integers $ x_{i} $ and $ y_{i} $ ($-10^{9} ≤ x_{i}, y_{i} ≤ 10^{9}$), separated by a single space and representing coordinates of the $ i $'th vertex of the polygon. Pairs of consecutive vertices, as well as the first and the last vertex, define sides of the polygon. Each of the following $ m $ lines contains three integers $ A_{i} $, $ B_{i} $ and $ C_{i} $ ($-10^{9} ≤ A_{i}, B_{i}, C_{i} ≤ 10^{9}$, $ A_{i}^{2} + B_{i}^{2} > 0$), separated by single spaces and representing a straight line defined by equation $ A_{i}x + B_{i}y + C_{i} = 0$.

Output Format

Your program should print $ m $ lines to the standard output. $ i $'th line should contain the square of the distance between $ i $-th straight line and the polygon, written as an irreducible fraction, where numerator is separated from denominator by the / sign.

Example

Input

8 2
2 1
6 1
6 2
3 2
3 5
5 5
5 7
2 7
1 1 -2
1 0 -6

Output

1/2
0/1
problem_11853_1.jpg