import math n = int(input()) s = input() r = math.isqrt(n) if s == "Q" * n and r * r == n: print("Q" * r) else: print(-1)