#include <cstdio>
using namespace std;
struct node
{
int l;
bool f=0;
node *next=NULL;
}*h,*r,*p;
int main()
{
int n;
scanf("%d",&n);
h=new node;
r=h; h->l=0;
for (int i=1; i<=n; i++)
{
double a; int t;
scanf("%lf%d",&a,&t);
if ((h->l)<int(a*t))
{
for (int j=(h->l)+1; j<=int(a*t); j++)
{
(h->l)++;
p=new node;
p->l=j;
r->next=p;
r=p;
}
}
p=h->next;
for (int j=1; j<=t; j++)
{
int s=int(a*j);
while((p->l)<s) p=p->next;
p->f=!(p->f);
}
}
p=h->next;
while(1)
{
if ((p->f)==1)
{
printf("%d",p->l);
return 0;
}
else p=p->next;
}
}