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. N people came to the feast, numbered from 1 to N. Person k has eaten Ak kilograms of meat so far. Bajs will hand out his ham in exactly the ratio B1:B2:⋯:BN, 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,…,N. Equal weights are fine. Pick a total amount of ham that gets him what he wants.
The first line contains the integer N, the number of candidates for the man of the year (2≤N≤1000).
Each of the next N lines contains two integers Ak and Bk (0≤Ak,Bk≤106). At least one Bk is not 0.
If no total amount of ham from 0 to 107 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/q on a single line. Here q is at least 1, and an integer answer is written with q equal to 1. For a smallest total of 10.5, print 21/2.
Take the first example. Handing out 10.5 kilograms in the ratio 1:2:0 gives 3.5, 7 and 0 kilograms. Adding what each person already ate gives totals of 10.5, 10 and 10 kilograms, which is a valid order. Any smaller amount breaks the order, so the smallest total is 10.5 and the answer is 21/2.