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