def parCondense(form, tar):
    """
    Performs paranthesis reduction at a particular depth.

    Parameters
    ----------
    form : string
        Formula.
    tar : int
        Target depth for paranthesis condensation.

    Returns
    -------
    ans : string
        The condensed paranthesis form of the given formula.
    """
    form += '@'
    ans = ""
    temp = ""
    ref = ""
    refctr = 0
    ctr = 0
    for ch in form:
        if(ch == '('):
            ctr += 1
        if(ctr >= tar):
            temp += ch
        else:
            if(len(ref) > 0):
                ans += ref
                ans += str(refctr) if refctr > 1 else ""
                ref = ""
                refctr = 0
            ans += ch
        if(ch == ')'):
            if(ctr == tar):
                if(temp == ref):
                    refctr += 1
                else:
                    ans += ref
                    ans += str(refctr) if refctr > 1 else ""
                    ref = temp
                    refctr = 1
                temp = ""
            ctr -= 1
    ans = ans[:-1]
    return ans