#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int a = 0, b = 0; for(int i = 0 ;i < n; i++) { int t; string s; cin >> t >> s; a += min(12 * t / 1000, (int)s.size()); b += max(0, (int)s.size() - 12 * t / 1000); } cout << a << " " << b << '\n'; return 0; }