I=input N=int(I()) R=int(N**0.5) S=I() T=S[:R] print([-1,T][[S,T]==[T*R,"Q"*R]])