# -*- coding: utf-8 -*- N = int(input()) correct_type = 0 typo = 0 for i in range(N): time, type_string = input().split() if 1000 / 12*len(type_string) <= int(time): correct_type += len(type_string) else: typed_string = -1 used_time = int(time) while 0 < used_time: used_time -= 1000 / 12 typed_string += 1 correct_type += typed_string typo += (len(type_string) - typed_string) print(correct_type, typo)