It seems that Borya is seriously sick. He is going visit *n* doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor 1, then doctor 2, then doctor 3 and so on). Borya will get the information about his health from the last doctor.

Doctors have a strange working schedule. The doctor *i* goes to work on the *s*<sub class="lower-index">*i*</sub>-th day and works every *d*<sub class="lower-index">*i*</sub> day. So, he works on days *s*<sub class="lower-index">*i*</sub>, *s*<sub class="lower-index">*i*</sub> + *d*<sub class="lower-index">*i*</sub>, *s*<sub class="lower-index">*i*</sub> + 2*d*<sub class="lower-index">*i*</sub>, ....

The doctor's appointment takes quite a long time, so Borya can not see more than one doctor per day. What is the minimum time he needs to visit all doctors?
First line contains an integer *n* — number of doctors (1 ≤ *n* ≤ 1000). 

Next *n* lines contain two numbers *s*<sub class="lower-index">*i*</sub> and *d*<sub class="lower-index">*i*</sub> (1 ≤ *s*<sub class="lower-index">*i*</sub>, *d*<sub class="lower-index">*i*</sub> ≤ 1000).
In the first sample case, Borya can visit all doctors on days 2, 3 and 4.

In the second sample case, Borya can visit all doctors on days 10 and 11.
3
2 2
1 2
2 2
4
2
10 1
6 5
11
3
6 10
3 3
8 2
10
4
4 8
10 10
4 2
8 2
14
5
7 1
5 1
6 1
1 6
6 8
14
6
1 3
2 5
4 7
7 5
6 8
8 8
16
10
4 10
8 7
6 5
2 1
2 3
8 8
2 4
2 2
6 7
7 9
34
1
1 1
1
1
1000 1000
1000
42
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
83
2
5 5
5 1
6
2
5 5
5 5
10
2
1 1
1 1
2
2
1 6
7 1
7
2
4 3
4 5
9
2
1 2
1 3
4
3
2 3
5 1
2 1
6
2
2 1
6 3
6
3
10 1
4 4
12 1
13
2
2 2
10 2
10
2
1 1
1000 2
1000
14
1000 1
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1 1
13001
2
2 4
2 1
3
3
1 100
100 3
200 1
200
7
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1 1
6001
2
5 5
15 5
15
2
2 2
2 4
6
2
1 1
10 1
10
2
10 1
100 1
100
15
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1000 1000
1 1
14001
3
2 1
1 3
4 7
11
2
5 5
100 5
100
2
1 10
2 30
2
4
2 2
2 2
2 2
2 2
8
1
10 10
10
n = int(input())
result = 0
for i in range(n):
	s, d = map(int, input().split())
	while s<=result:
		s+=d
	result = s
print(result)