<>;map{$_=reverse;$i++while s/^\s*R(R*)G((R*G[RG]*)|([RW]*))W/$1.$3.$4=~y#W##dr/e;$i=!print"im"x!($i&&!$_),possible,$/}<>