<>;map{$_=reverse;$i++while s/^\s*R(R*)G(.*?)W/$1$2/||s/^\s*RGW+//;$i=!print"im"x!($i&&$_),possible,$/}<>