a=input().split() list=[] for j in a: if j[0]=="Q"or j[0]=="q": list.append(j) for i in list: print(i)