G=B=0;exec('T,S=input().split();s=len(S);g=min(s,int(int(T)*6/500));G+=g;B+=s-g;'*int(input()));print(G,B)