for l in io.lines()do a,b,c=l:match("(.+) (.+) (.+)");print(b:find(a,1,1)and c:find(b,1,1)and"YES"or"NO")end