Initialize all entries of lookup table
for ( let i = 0 ; i < 50 ; i ++ ) for ( let j = 0 ; j < 1000 ; j ++ ) for ( let k = 0 ; k < 1000 ; k ++ ) for ( let l = 0 ; l < 2 ; l ++ ) lookup [ i ] [ j ] [ k ] [ l ] = - 1 ;