
#print 'input strings >>>> '
str = gets.chomp
str = str.split
freq = Hash.new
mlw = [""],mfw = [""]
=begin
mlw = most longest word
mfw = most frequency word
=end

str.each do |i|
  if mlw.length < i.length
    mlw = i
  end

  if freq.key?(i)
    freq[i] = freq[i] + 1
  else
    freq[i] = 1
  end

end

cnt = 0
freq.each do |w,f|
  if cnt < f
    cnt = f
    mfw = w
  end
end

#puts "inputed grammer >>>  #{str}"

puts "#{mfw} #{mlw}"

