package main import ( "fmt" "strings" ) func solve() (res string) { res = "impossible" var S string fmt.Scan(&S) sr := strings.NewReader(S) var W0, W1, G, R int for { b, e := sr.ReadByte() if e != nil { break } switch b { case byte('W'): W0++ W1++ case byte('G'): W0 = 0 G++ case byte('R'): R++ } if R > G || G > W1 { return } } if W0 == 0 && G == R { res = "possible" } return } func main() { var N int fmt.Scan(&N) for i := 0; i < N; i++ { fmt.Println(solve()) } }