n = int(input()) s = input() q = s.count('Q') if q != n: print(-1) exit() import math x = math.floor(q ** 0.5 + 0.0001) if 'Q' * (x * x) != s: print(-1) else: print('Q' * x)