<>;sub r{$j=$t[my$i=pop];$j?$t[$i]=r($j):$i}s/ \d+//,$p=(r$&)-(r$'),$`&&print($p?NO:YES,$/)||$p&&($t[r$&]=$')for<>