<>;map$'?$@[$_+$']+=$-=$@[$_]+$`-$@[$_+$']:(${(a..c)[$@[$_]<=>$`]}=$_),sort{1}!/ | /..@@for<>;print$a||1,$/,$b-1||inf