n = int(input()) s = input() x = 0 for c in s: if c == 'Q': x += 1 if x == 1: print(s) else: print(-1)