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