#!/usr/bin/python # -*- coding: utf-8 -*- # roiti46 さんのをカンニング T = input() for t in range(T): inp = raw_input() w = last = 0 needG = False # last: 要終電本数 # needG: 要緑 t/f for s in inp: #緑より多く赤 or 白より多く緑 はだめ if s == 'G': last += 1 w -= 1 needG = False elif s == 'R': last -= 1 else: #s == 'W' w += 1 needG = True if last < 0 or w < 0: print 'impossible' break else: if last == 0 and needG == False: print 'possible' else: print 'impossible'