n = int(input()) S = input() for s in S: if s != "Q": print(-1) exit() for i in range(10**3): if i*i == n: print("Q"*i) exit() print(-1)