import sys N = int(input()) S = input() qnum = 0 for i in S: if i == "H": print (-1) sys.exit() elif i == "Q": qnum += 1 for i in range(1000): if i ** 2 == qnum: rp = i break else: print (-1) sys.exit() code = S[:N//rp] #print (code) for i in range(N): if S[i] != code[i % len(code)]: print (-1) sys.exit() print (code)