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