package main import ( "bufio" "fmt" "os" "regexp" "strconv" "strings" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) t := nextInt() r := regexp.MustCompile(`G.*?R`) for i := 0; i < t; i++ { b := []byte(strings.Replace(nextLine(), "W", "", -1)) for j := 0; j < 3; j++ { loc := r.FindIndex(b) if loc == nil { break } b[loc[0]], b[loc[1]-1] = 'W', 'W' b = []byte(strings.Replace(string(b), "W", "", -1)) } if len(b) == 0 { fmt.Println("possible") continue } fmt.Println("impossible") } } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }