N = int(input()) S = input() x = -1 for i in range(N+1): if i*i==N: x = i if x==-1 or S!='Q'*N: print(-1) else: print('Q'*x)