d=[] n,q=gets.split.map &:to_i q.times{l=gets;a,x,y=l.split.map{|v|b=v=v.to_i;d[b]=v=d[v]while d[v];v};a<1?x!=y&&d[y]=x :y&&puts(x==y ?:YES: :NO)}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page