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