n = gets.to_i x, y = 0, 0 n.times do |i| a, b = gets.split a = a.to_i l = b.length pos = (12 * a) / 1000 x += [pos, l].min y += [l-pos, 0].max end puts [x, y].join(" ")