while True: a = raw_input().strip().split() n=len(a) if n>300: break for v in a: if (v[0]=='Q') or (v[0]=='q'): print v