class Treap
  def initialize
    @root = nil
  end

  def add(x)
    if @root
      @root = @root.add(x)
    else
      @root = Node.new(x)
    end
  end

  def query(x)
    if @root
      @root.query(x)
    else
      0
    end
  end

  class Node
    def initialize(x)
      @value = x
      @priority = rand(0)
      @left_child = @right_child = nil
      @count = 1
    end

    def add(x)
      @count += 1
      if x <= @value
        if @left_child
          @left_child = @left_child.add(x)
        else
          @left_child = Node.new(x)
        end
        if @left_child.priority > @priority
          return rotate_right
        else
          return self
        end
      else
        if @right_child
          @right_child = @right_child.add(x)
        else
          @right_child = Node.new(x)
        end
        if @right_child.priority > @priority
          return rotate_left
        else
          return self
        end
      end
    end

    def rotate_right
      v = @left_child
      @left_child = v.right_child
      v.right_child = self
      update
      v.update
      return v
    end

    def rotate_left
      v = @right_child
      @right_child = v.left_child
      v.left_child = self
      update
      v.update
      return v
    end

    def update
      @count = (@left_child ? @left_child.count : 0) + 1 + (@right_child ? @right_child.count : 0)
    end

    def query(x)
      if x <= @value
        if @left_child
          return @left_child.query(x)
        else
          return 0
        end
      else
        if @right_child
          return (@left_child ? @left_child.count : 0) + 1 + @right_child.query(x)
        else
          return @count
        end
      end
    end

    attr_accessor :priority, :left_child, :right_child, :count, :max
  end
end

n = gets.to_i
plus_tree = Treap.new
minus_tree = Treap.new
timeline = []
ranges = []
n.times do
  l, r = gets.split.map(&:to_i)
  ranges << [l, r]
  plus_tree.add(l)
  minus_tree.add(r)
  timeline << [l, +1]
  timeline << [r, -1]
end

policy1 = ranges.map {|l, r| plus_tree.query(r) - minus_tree.query(l + 1) }.max

timeline.sort!
policy2 = 0
k = 0
until timeline.empty?
  t = timeline[0][0]
  while !timeline.empty? && timeline[0][0] == t
    _, diff = timeline.shift
    k += diff
  end
  policy2 = k if k > policy2
end

puts "#{policy1} #{policy2}"
