n=int(input()) s=input() if s.count("Q")==1: print(s) else: print(-1)