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