Initialising lca and dist values with - 1 and 0 respectively
for ( let i = 1 ; i <= n ; i ++ ) { lca [ i ] = new Array ( log ) ; dist [ i ] = new Array ( log ) ; for ( let j = 0 ; j < log ; j ++ ) { lca [ i ] [ j ] = - 1 ; dist [ i ] [ j ] = 0 ; } }