Two players are competing in a two-player game involving $$$n$$$ decks of cards. The $$$i$$$-th deck contains $$$p_i$$$ red cards and $$$q_i$$$ blue cards. The cards in each deck are indistinguishable from one another when placed face down.
The game consists of $$$n$$$ rounds, with each round played as follows:
Given that both players are playing optimally and know the exact composition of each deck (i.e., the number of red and blue cards in each deck), determine the probability that the player who starts as the dealer will win the game.
Let $$$P = 1\,000\,000\,007$$$. 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 of the input contains an integer $$$n$$$ ($$$1 \le n \le 10^6$$$), the number of decks. The $$$i$$$-th of the following $$$n$$$ lines contains two integers $$$p_i$$$ and $$$q_i$$$ ($$$0 \le p_i, q_i \le 10^6$$$, $$$p_i + q_i \gt 0$$$): the number of red cards and the number of blue cards in the $$$i$$$-th deck, respectively.
Print the answer modulo $$$1\,000\,000\,007$$$ in a single line.
11 2
333333336
42 33 54 71 4
96818183
In the first example, the dealer has $$$\frac{1}{3}$$$ chance of winning if the guesser flips up a red card.