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