#include <iostream>
#include <cmath>
using namespace std;
double n,a[25],b[25],h=10,d,s;
int main()
{
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
if(h-a[i]>0){
h-=a[i];
s+=b[i];
if(h>10){
h=10;
}
}
}
while(1){
if(pow(2,d)>s){
cout<<d<<" "<<s;
return 0;
}
else{
s-=pow(2,d);
d++;
}
}
}