a=*0..gets.to_i loop{b,c,d=gets.split.map{|l|m=l=l.to_i 1until m==m=a[m] a[l]=m} b>0?puts(c==d ?:YES:"NO"):a[c]=d}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page