local n = io.read("*n", "*l") local s = io.read() y = 0 for i = 1, n do if s:sub(i, i) == "H" then print(-1) os.exit() end if s:sub(i, i) == "Q" then y = y + 1 end end z = math.sqrt(y) if z * z == y then print(string.rep(s, z)) elseif (z + 1) * (z + 1) == y then print(string.rep(s, z + 1)) else print(-1) end