[*$<].map{|s|a,b,c=s.split;puts b.index(a)&&c.index(b)?:YES: :NO}