I=input N=int(I()) R=int(N**0.5) S=I() T=S[:R] b=c=0 for t in T: if t=='H':b=1 if t=='Q':c+=1 print([-1,T][[S,T,b,c]==[T*R,"Q"*R,0,R]])