s//123 456 789 z147,258,369,159,357/;$p=O;{/z/;print$`,$p^=O^X;/(.)\1\1/?die$1:/\d/||die Tie;$?=<>until s/$?/$p/g;redo}