$h[$_]=rand for 1..<>; ($q,$L,$R,$K)=glob, '!'eq$q? $h{$h+=$K*($h[$L]-$h[$R])}//=$.-1 : print$h{$h}+0,$/ while<>