gets h={?W=>0,?G=>1,?R=>-1} $<.map{|s| v=0;puts s.chop.chars.all?{|c|v+=h[c];v>=0}&&s=~/G+R+$/?:possible:'impossible' }