Limits 2s, 512 MB

After getting rejected by his crush for 7th time, Rakib decided to leave all these silly worldly things and sink into the ocean of books. For some reasons, he started to like the letter ‘S’ from then. Anyways, he has invited his n1n-1 friends on a party and arranged a weird contest. Each person (including Rakib) takes a book from his collection and sits in n chairs numbered serially from 1 to nn. The ii-th person (according to chair number) gets a book consisting of yiy_i words and among them, xix_i words contain the letter ‘S’.

The game goes as follows. At each round, everyone randomly opens a page from his own book and then randomly chooses a word. If no one gets a word which contains ‘S’, the game goes to next round. Otherwise among all the persons who got a word containing ‘S’, the person with the minimum chair number is declared the winner and the game ends.

As you might suspect, everyone wants to know the probability of them winning the contest. Can you help them?

It can be shown that all the probabilities can be shown as PQ\frac{P}{Q} where PP and QQ are co-prime integers and Q≢0mod(109+7)Q \not\equiv 0 \mod (10^9+7). Print the value of PQ1mod(109+7)P⋅Q^{-1} \mod (10^9+7) for each probability.

Input

The first line contains the number of test cases tt (1t101 ≤ t ≤ 10). Each test case begins with a line containing a single integer nn (1n1000001 ≤ n ≤ 100000), the number of people in the party (including Rakib). Each of the following nn lines contain two integers, xix_i and yiy_i (1yi1000001 ≤ y_i ≤ 100000, 1xiyi1 ≤ x_i ≤ y_i).

Output

For each case, output nn integers in a line separated by spaces. The ii-th integer should be the probability of the ii-th person winning the game as P.Q1mod(109+7)P.Q^{-1} \mod (10^9+7), for PP and QQ defined above.

Sample

InputOutput
2
2
1 2
2 3
3
1 2
4 6
3 4

200000002 800000006 
869565224 913043485 217391306 

Let PP be a prime. It can be shown that for any integer AA (1A<P1 ≤ A < P), there exists a unique integer BB (1B<P1 ≤ B < P) such that AB1modPAB ≡ 1 \mod P. This BB is called the modular inverse of AA with respect to PP and is also expressed as A1A^{-1}.

Fermat's Little Theorem: If PP is a prime and AA is an integer co-prime with PP, then AP11modPA^{P-1} ≡ 1 \mod P.

Submit

Login to submit.

Statistics

0% Solution Ratio
Toph uses cookies. By continuing you agree to our Cookie Policy.