<>,@$_=sort{$a-$b}glob<>for 0,1;map{$$_++while($m)=grep$_>$m,@{$|--};$|=1}a,b;print$a>$b?$a:$b