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