System.in.eachLine{println it=~/^(.*) (.*\1.*) .*\2/?"YES":"NO"}