#include <bits/stdc++.h>
using namespace std;
const int N = 0;
int n;
int a[20],b[20];
unsigned long long s,ss;
int main(){
freopen("ccyz.in","r",stdin);
freopen("ccyz.out","w",stdout);
scanf("%d",&n);
for(int i = 1;i <= n;i++){
scanf("%d%d",&a[i],&b[i]);
}
ss = a[1];
s = a[1] + b[1];
for(int i = 2;i <= n;i++){
while((s - b[i]) % a[i]){
s += ss;
}
ss *= a[i];
}
cout<<s<<endl;
return 0;
}