N = int(input()) Tok = 0 Tng = 0 for _ in range(N): t, s = input().split() sn = len(s) tn = int(t) * 12 // 1000 tok = min(sn, tn) tng = sn - tok Tng += tng Tok += tok print(Tok, Tng)