map{/ /&&print-($x=s/.\s/++$$m x$&/ger*1e9)%$m+$x||$m,$/;$m=$_}<>