def find_lca(self, u, v):
    (du, dv) = (self.depth[u], self.depth[v])
    if (du > dv):
        (u, v) = (v, u)
        (du, dv) = (dv, du)
    d = (dv - du)
    for i in range(d.bit_length()):
        if ((d >> i) & 1):
            v = self.ancestors[i][v]
    if (v == u):
        return v
    for i in range((du.bit_length() - 1), (- 1), (- 1)):
        (nu, nv) = (self.ancestors[i][u], self.ancestors[i][v])
        if (nu == nv):
            continue
        (u, v) = (nu, nv)
    return self.ancestors[0][u]
def find_lca(self, u, v):
    (du, dv) = (self.depth[u], self.depth[v])
    if (du > dv):
        (u, v) = (v, u)
        (du, dv) = (dv, du)
    d = (dv - du)
    for i in range(d.bit_length()):
        if ((d >> i) & 1):
            v = self.ancestors[i][v]
    if (v == u):
        return v
    for i in range((du.bit_length() - 1), (- 1), (- 1)):
        (nu, nv) = (self.ancestors[i][u], self.ancestors[i][v])
        if (nu == nv):
            continue
        (u, v) = (nu, nv)
    return self.ancestors[0][u]