s=list(map(str,input().split())) L=len(s) i=0 while i<L: if s[i][0]=='Q'or s[i][0]=='q': print(s[i]) i+=1