eval'A,B='+gets.split*?, l=[A,B].map(&:size).max r=A<=>B l.times.any?{|i|[A[i],B[i]].sort==[?4,?7]&&r=B[i]<=>A[i]} $><<[0,A,B][r]