#coding: utf-8 ##yuki_35 import sys n=int(raw_input()) s=[[0 for i in xrange(2)] for j in xrange(n)] for i in range(n): l=raw_input().split() s[i][0]=int(l[0]) s[i][1]=l[1] ct=0 wt=0 tt=0 for i in xrange(n): chr_cnt=12*s[i][0]/1000 if len(s[i][1])<=chr_cnt: ct+=len(s[i][1]) else: ct+=chr_cnt wt+=len(s[i][1])-chr_cnt for i in xrange(n): tt+=len(s[i][1]) wt=tt-ct print ct,wt