#include<bits/stdc++.h>
using namespace std;
double n, x, a, l = 10, m, t;
int main(){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> x >> a;
if(l - x <= 0){
break;
}else if(l - x >= 10){
l = 10;
}else{
l -= x;
}
t += a;
int mc = 1;
if(m != 0){
for(int j = 1; j <= m; j++){
mc *= 2;
}
}
if(t >= mc){
t -= mc;
m++;
}
}
cout << m << " " << t;
return 0;
}