sub f{$r+=$a=!grep$_-$_[1]&&f($_,@_),@$_;$a}/ /&&push@{$`},$'+!push@{$'+0},$`for<>;f$_=1;print$r