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