def balanced_parentheses(n):
    output, path = [], []
    def visit(opened, closed):
        if len(path) == 2 * n:
            output.append(''.join(path))
            return
        if opened < n:
            path.append('(')
            visit(opened + 1, closed)
            path.pop()
        if closed < opened:
            path.append(')')
            visit(opened, closed + 1)
            path.pop()
    visit(0, 0)
    return output
