c=s=0 for i in range(int(input())): a,b=input().split();d=len(b);s+=d;c+=min(int(int(a)/1000*12),d) print(c,s-c)