($n,$x,$y)=glob<>;print sort{1}map"@{/^3/?($x,$y)=($y,-$x,++$r):((($s=$r-$_)&/ /?$u:$v)+=$s&2?$':-$'),[$x+$u,$y+$v]} ",sort{1}<>