gets $<.map{|s| s=s.chomp.reverse c=0 while s=~/^R+G.*W/ c+=1;s[?R]=s[?G]=s[?W]='' end puts c>0&&s=~/W*/?:possible:'impossible' }