gets puts$<.map{|s|t=0;"impossible"[s.chars{|c|t+=c>?V?1:c==?G?-1:0;t<0&&break}=~/^W*(?GW*\g*RW*)+$/&&s=~/GR+$/?2:0,10]}