f=u[a]?a=u[a],f:a while read a b c do r[y=f,a=b,y-f?u[y]=a,0:1]=$c done echo $r