#include <stdio.h>
#include <math.h>
int main()
{
int times=0;
double health=10;
double healthchange=0;
double upwater=0;
double count=0;
double mid2=0;
double mid=0;
scanf("%d",×);
for(int i=0;i<times;i++){
scanf("%lf %lf",&healthchange,&upwater);
mid2=count;
count=count+upwater;
mid=health;
health=health-healthchange;
if(health<=0){
health=mid;
count=mid2;
break;
}
}
double level=0;
double t=0;
while(count!=0){
if(count-pow(2.0,level)<0){
t=count;
count=0;
}else{
count=count-pow(2.0,level);
level++;
}
}
printf("%.0f %.0f",level,t);
return 0;
}