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