n=int(input()) s=input() if s.count("Q")==1: if s.count("H")==0: print(s) else: print(-1) elif s.count("Q")!=0: for i in range(2,n): if n%i==0: for j in range(n//i-1): if s[i*j:i*(j+1)]!=s[i*(j+1):i*(j+2)]: break else: t=s[:i] if t.count("Q")==n//i: print(t) break else: print(-1) else: print(-1)