Initialising lca and dist values with - 1 and 0 respectively
for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( lg ) : NEW_LINE INDENT lca [ i ] [ j ] = - 1 NEW_LINE dist [ i ] [ j ] = 0 NEW_LINE DEDENT DEDENT