N:=stdin nextByte- 49.{{}}do:(Q:=[:o|0to:N do:[:x|I:=-1.L:=o size.(o anySatisfy:[:v|L-(I:=I+1)=(x-v)abs|(x=v)])or:[L=N and:[o do:[:i|stdout<<i<<$ ].x printNl].{o,{x}}do:Q]]])
Note that non-ascii characters in the above source code will be escaped (such as \x9f).