N = int(input()) ans = 0 miss_type = 0 for i in range(N): date_type = input().split() time = int((12 / 1000) * int(date_type[0])) if len(date_type[1]) > time: ans = ans + time miss_type = miss_type + len(date_type[1]) - time else: ans = ans + len(date_type[1]) print(str(ans) + " " + str(miss_type))