N = int(input()) count = 0 miss = 0 for i in range(N): T, S = input().split() typ = 12*int(T) // 1000 words = len(S) if (typ - words) < 0: miss -= typ - words count += typ else: miss += 0 count += words print(int(count), int(miss))