n = int(input()) s = input() #[0, r) cnt = 0 for r in range(1, n + 1): cnt += s[r-1] == 'Q' if cnt * r == n: code = s[:r] if code * cnt == s: print(code) exit() print(-1) exit()