def main(): N = int(input()) S = tuple(tuple(input().split()) for _ in range(N)) complete = 0 lost = 0 for t, s in S: t = int(t) max_ = 12 * t // 1000 len_ = len(s) if len_ <= max_: complete += len_ lost += 0 else: complete += max_ lost += len_ - max_ print(complete, lost) main()