#2、3、5、6
#include<bits/stdc++.h>
using namespace std;
int main(){
double a;
int T,t,sum=0,tt=0;
bool b[2001000]={false};
cin>>T;
while(T--){
cin>>a>>t;
tt=max(tt,t);
for(int i=1;i<=t;i++){
int bi=a*i;
if(b[bi]) b[bi]=false;
else b[bi]=true;
}
}
for(int i=1;i<=tt;i++){
if(b[i]){
cout<<i;
return 0;
}
}
return 0;
}