The lord has vanished without a trace.
Inside a secluded castle, the royal family gathered to claim his inheritance. One by one, they perished—locked rooms, vanished alibis, headless corpses—until only two remained: Ange and Beatrice.
The lord's will was sealed within an epitaph. It was said that whoever deciphered it would become the rightful heir. Ange solved the riddle... but only a moment too late. At the end of the path, Beatrice was already waiting with a smile.
The inheritance is the family estate: a convex polygon within which stand two ancient landmarks. Yet Beatrice, in her magnanimity, offered Ange a chance to share the rule. The land will be divided by the following ritual:
Beatrice, having arrived first, always claims the larger half. Ange receives the smaller one.
Your task is to compute the expected difference in area between Beatrice's region and Ange's region.
Let $$$P = 10\,000\,000\,019$$$. P is a prime number. It can be shown that the answer can be expressed as an irreducible fraction $$$\frac{x}{y}$$$ where $$$x$$$ and $$$y$$$ are integers and $$$y \not\equiv 0 \pmod P$$$. Output the integer equal to $$$x\cdot y^{-1} \pmod P$$$. In other words, output such an integer $$$a$$$ that $$$0 \le a \lt P$$$ and $$$a\cdot y=x \pmod P$$$.
The first line contains a single integer $$$N$$$ — the number of vertices of the polygon $$$(3 \leq N \leq 10^5)$$$.
Each of the next $$$N$$$ lines contains two integers $$$x_i, y_i$$$ $$$(-10^9 \leq x_i, y_i \leq 10^9)$$$, representing the coordinates of the polygon's vertices, given in clockwise order. The polygon is guaranteed to be convex , and no three consecutive vertices are collinear.
The last line contains four integers $$$x_p, y_p, x_q ,y_q$$$ $$$(-10^9 \leq x_p, y_p, x_q ,y_q \leq 10^9)$$$, representing the coordinates of the two landmarks, one at $$$(x_p,y_p)$$$ and another at $$$(x_q,y_q)$$$, which both are guaranteed to lie strictly inside the polygon.
Print the answer modulo $$$10\,000\,000\,019$$$ in a single line. If it is impossible to select the chord to fit the criteria, print $$$-1$$$.
70 0-1 21 55 46 15 -12 -23 4 3 1
11
60 54 36 02 -10 0-1 31 0 0 1
5000000010
310 00 05 103 1 7 3
-1
The polygon in the first test case can be visualized as follows:
Figure L.1: The polygon showing the two landmarks (inside points) and all chords that successfully separate them. Depending on the language, the expected difference or other intermediate values can exceed the range of 32-bit or even 64-bit integers in worst cases. To avoid overflow: