Ham and the man of the year

No attempts yetTime limit1sMemory limit128 MB

Problem

Melita has just come back from the yearly pig feast. In Croatia this is a normal event. The best part was how much food there was. Spicy sausages, ham, black pudding, teewurst, top quality bacon and čvarci, all with warm white bread and butter. After those appetizers came a deep pot of sarma (Melita ate about twenty of them) and a large platter of roast pork so soft it almost melted in the mouth. They washed it all down with the best dry white wine, which only made them hungrier.

The butcher Bajs saved his award winning ham for the very end. NN people came to the feast, numbered from 11 to NN. Person kk has eaten AkA_k kilograms of meat so far. Bajs will hand out his ham in exactly the ratio B1:B2::BNB_1 : B_2 : \dots : B_N, but he has not decided how many kilograms he will hand out.

When the feast ends, the man of the year is announced. The ranking follows the total weight of meat each person ate, and Bajs changes that ranking just by choosing how much ham to hand out. People have offered him bribes many times and he refused every time, saying he is an honest man who would not hurt a fly.

Bajs cares about order. Lining people up from the one who ate the most kilograms down to the one who ate the least, he wants the numbers to come out exactly as 1,2,3,,N1, 2, 3, \dots, N. Equal weights are fine. Pick a total amount of ham that gets him what he wants.

Input

The first line contains the integer NN, the number of candidates for the man of the year (2N10002 \le N \le 1000).

Each of the next NN lines contains two integers AkA_k and BkB_k (0Ak,Bk1060 \le A_k, B_k \le 10^6). At least one BkB_k is not 0.

Output

If no total amount of ham from 0 to 10710^7 kilograms, both ends included, produces the wanted order, print -1 on a single line.

Otherwise print the smallest such total, in kilograms, as an irreducible fraction p/qp/q on a single line. Here qq is at least 1, and an integer answer is written with qq equal to 1. For a smallest total of 10.510.5, print 21/2.

Hint

Take the first example. Handing out 10.510.5 kilograms in the ratio 1:2:01 : 2 : 0 gives 3.53.5, 77 and 00 kilograms. Adding what each person already ate gives totals of 10.510.5, 1010 and 1010 kilograms, which is a valid order. Any smaller amount breaks the order, so the smallest total is 10.510.5 and the answer is 21/2.