n=int(input()) x=0;y=0 for i in range(n): t,s=map(str,input().split()) t=int(t) x+=min(12*t//1000,len(s)) y+=max(len(s)-12*t//1000,0) print(x,y)