#include <iostream>
#include <cstdio>
using namespace std;
bool vis[2000005];
int main(){
int t, n;
cin >> t;
double k;
while(t--){
cin >> k >> n;
for(int i = 1; i <= n; i++){
vis[int(i * k)] ^= 1;
}
}for(int i = 1;; i++){
if(vis[i]){
cout << i;
return 0;
}
}
}