Function to build the segment tree
function build ( node , start , end , arr , k ) { if ( start == end ) { tree [ node ] = ( 1 * arr [ start ] ) % k ; return ; } let mid = ( start + end ) >> 1 ; build ( 2 * node , start , mid , arr , k ) ; build ( 2 * node + 1 , mid + 1 , end , arr , k ) ; tree [ node ] = ( tree [ 2 * node ] * tree [ 2 * node + 1 ] ) % k ; }