def comp(a, b) if a.length != b.length return a.length <=> b.length end (0...a.length).each do |i| if a[i] == b[i] next elsif a[i] == 4 && b[i] == 7 return 1 elsif a[i] == 7 && b[i] == 4 return -1 else return a[i] <=> b[i] end end return 0 end a, b = gets.chomp.split(" ").map{|s|s.chars.map &:to_i} if comp(a, b) == -1 puts b*'' else puts a*'' end