#include<bits/stdc++.h>
using namespace std;
int n,t[5005],x,c=0;
bool d[2000005];
double a[5005];
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i]>>t[i];
for(int j=1;j<=t[i];j++){
x=floor(a[i]*j);
if(d[x]==0){
d[x]=1;
}
else{
d[x]=0;
}
}
if(t[i]>c){
c=t[i];
}
}
for(int i=1;i<=c;i++){
if(d[i]==1){
cout<<i;
return 0;
}
}
return 0;
}