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