# include <iostream>
using namespace std;
int main ()
{
int k;
cin>>k;
int x = 0,y = 0;
while(k--)
{
int a,b;
cin>>a>>b;
if (a==20&&(b == 5||b == 10)) y += 10;
else if (b == 20&&(a == 5||a == 10)) x += 10;
else if (a > b) x += a-b;
else if (a < b) y += b-a;
}
cout<<x<<' '<<y;
return 0;
}