import math N = int(input()) x = 0 y = 0 for i in range(0, N): T, S = input().split() ty= math.floor(12 / 1000 * int(T)) if ty < len(S): x += ty y += len(S) - ty else: x += len(S) print("{0} {1}".format(x, y))