N=int(input()) y=n=0 for i in range(N): t,s=map(str,input().split()) t=int(t) s=len(s) ty=12*t//1000 if s<=ty: y+=s else: y+=ty n+=s-ty print(y,n)