import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int sum = 0; int ok = 0; for(int i = 0; i < n; i++) { int t = sc.nextInt(); int l = sc.next().length(); sum += l; ok += Math.min(12 * t /1000, l); } System.out.println(ok + " " + (sum - ok)); } }