<>;map{$_=reverse;1while s/^\s*R(.*?)G(.*?)W/$1$2/;print"im"x/[GR]/,possible,$/}<>