Under construction

Still being built. Things may change

Coloring the Infinite Plane

Time limit2sMemory limit1024 MB

Summary
Given N integer vectors, find the density of the lattice they generate in the plane, printed as a fraction modulo 1,000,000,007.
Level

Medium6 of 10

Topics
Math, Number theory
Solved
No attempts yet

Problem

Every lattice point on the coordinate plane is painted white. Jiho stands on a point and can move by (x_i,y_i)(x\_i, y\_i) or by (−x_i,−y_i)(-x\_i, -y\_i) from that point.

Starting from the origin (0,0)(0, 0), color black every point that Jiho can reach.

For example, suppose Jiho can move by (2,0)(2,0), (2,2)(2,2), and (0,2)(0,2). The figure below shows this case.

The red point is the origin, and the blue points are the points Jiho can reach from the origin in one move. Since Jiho can also move by (−x_i,−y_i)(-x\_i, -y\_i), the green points are also reachable from the origin in one move. Points reachable after several moves are colored black. Every point except the white ones can be reached from the origin.

The fraction of lattice points that are black is a rational number. In the example above, only points with both coordinates even are colored, so the fraction is 1/41/4.

Write this rational number as an irreducible fraction ab\frac{a}{b}, and print (a⋅b−1) mod 1 000 000 007(a \cdot b^{-1}) \bmod 1\,000\,000\,007. Here 1 000 000 0071\,000\,000\,007 is prime.

If the fraction is 00, print 00. If it is 11, print 11. The fraction is always rational, and no test case has a denominator bb that is a multiple of 1 000 000 0071\,000\,000\,007. In other words, the answer always exists.

Input

The first line contains NN. Each of the next NN lines contains x_ix\_i and y_iy\_i separated by a space, for 1≤i≤N1 \le i \le N.

Output

Print the answer on the first line.

Constraints

  • 2≤N≤1 000 0002 \le N \le 1\,000\,000
  • −109≤x_i,y_i≤109-10^9 \le x\_i, y\_i \le 10^9 (1≤i≤N1 \le i \le N)

Hint

Moving from a point (x,y)(x,y) by (x′,y′)(x',y') takes you to the point (x+x′,y+y′)(x+x', y+y').

The black ratio AA is defined precisely as follows. For every ϵ>0\epsilon>0, there is a positive integer NN such that for every integer n>Nn > N, the fraction of colored points among all lattice points (x,y)(x,y) with −n≤x,y≤n-n \le x,y \le n differs from AA by less than ϵ\epsilon. The problem guarantees that AA always exists and is rational.

For a prime pp and integers a,ba,b with gcd⁡(b,p)=1\gcd(b,p)=1, (a⋅b−1) mod p(a \cdot b^{-1}) \bmod p is the smallest nonnegative integer xx that satisfies bx≡a(modp)bx \equiv a \pmod{p}.

Examples2

  1. Example 1

    Input
    3
    2 0
    2 2
    0 2
    
    Expected output
    250000002
    
  2. Example 2

    Input
    2
    1 2
    2 4
    
    Expected output
    0