Day of Abundance#2491

Day of Abundance

1 second
64 megabytes
Hard

In the port of Greenland, situated on the shore of the Multicolored Sea, ships occasionally dock, bringing various goods that are later sold in the shops of the nearby village. There are ships, each arriving at the port with a particular periodicity.

Life is hard for the villagers on days when not a single ship arrives. Not only do they have to make their way to the shop through barbed wire and minefields—risking a fall into a sewer manhole—but even in the shop, there is nothing to buy. And it is simply impossible to travel to a more civilized place, where there is a market or supermarket, due to the excessive cost of minibuses, which are so overcrowded that they are stuffed with herring rather than people.

Now, you can easily imagine the joy of the "Greenlanders" when at least one ship docks at the port, as then at least some products will finally appear in the shops. But you can hardly imagine the joy the villagers feel on the day when all ships dock at the port together. This day is rightfully considered a day of abundance.

The residents of Greenland implore you to write a program that determines how long they must wait for such a day.

Input

The first line of the input contains the number of ships (1 \leq N \leq 100). The following lines each contain two natural numbers: the first day a particular ship arrives at the port, and the number of days after which it will arrive again. All numbers do not exceed 10^9.

Output

Output the number of the first day when all ships will be at the port together. If no such day exists, output . You may assume that if such a day exists, its number does not exceed 2 \cdot 10^9.

Examples

Example 1

Loading
Loading