class English
  def initialize
    @lists = {}
    @max_test = ""
    @max_size = 0
    @fre_text = ""
    @text = $stdin.gets.chomp.split(' ')

    @text.each do |t|
      if @max_size < t.size
        @max_size = t.size
        @max_text = t
      end

      if @lists.has_key?(t)
        @lists[t] += 1
      else
        @lists[t] = 1
      end
    end

    max = 0

    @lists.each_pair do |t, count|
      if max < count
        max = count
        @fre_text = t
      end
    end

    puts "#{@fre_text} #{@max_text}"
  end
end

e = English.new