import java.io.*; import java.util.*; import java.util.stream.*; // 処理 class Process { private PrintWriter printWriter; private int[] T; private String[] S; Process(PrintWriter printWriter, int[] T, String[] S) { this.printWriter = printWriter; this.T = T; this.S = S; } private int stringLengthSum(String[] S) { int sum = 0; for(String s : S) { sum += s.length(); } return sum; } // 結果を出力 void printResult() throws IOException { int numOfCharsCanType = 0; int sumOfCharsCanType = 0; for(int i = 0; i < T.length; i++) { numOfCharsCanType = 12 * T[i] / 1000; sumOfCharsCanType += (numOfCharsCanType > S[i].length()) ? S[i].length() : numOfCharsCanType; } printWriter.println(sumOfCharsCanType + " " + (stringLengthSum(S) - sumOfCharsCanType)); } } public class Main { public static void main(String[] args) throws IOException { var bufferedReader = new BufferedReader(new InputStreamReader(System.in)); var printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); // 入力 int N = Integer.parseInt(bufferedReader.readLine().trim()); var T = new int[N]; var S = new String[N]; var input = new String[2]; for(int n = 0; n < N; n++) { input = bufferedReader.readLine().trim().split("[ ]+"); T[n] = Integer.parseInt(input[0]); S[n] = input[1]; } // Process クラスで処理を行う var process = new Process(printWriter, T, S); process.printResult(); // 各ストリームを閉じる // 出力ストリームを閉じるときに標準出力に文字を出力する bufferedReader.close(); printWriter.close(); } }