N=int(input())
S=input()
Q=0
H=False
for c in S:
	if c=='Q':Q+=1
	if c=='H':H=True
K=int(Q**0.5)
if not H and Q>0 and K*K==Q and N%K==0:
	ok=True
	for i in range(N-N//K):
		ok&=S[i]==S[i+N//K]
	if ok:
		print(S[:N//K])
		exit(0)
print(-1)