N = int(input()) results = [list(input().split()) for _ in range(N)] d = 0 r = 0 for x in [[int(t) * 12 // 1000, len(s[0])] for t, *s in results]: done = min(x) rest = x[1] - done if x[1] - done > 0 else 0 d += done r += rest print("%d %d" % (d, r))