Function to build the segment tree
def build ( node , start , end , arr , k ) : NEW_LINE INDENT if ( start == end ) : NEW_LINE INDENT tree [ node ] = ( arr [ start ] ) % k ; NEW_LINE return ; NEW_LINE DEDENT mid = ( start + end ) >> 1 ; NEW_LINE build ( 2 * node , start , mid , arr , k ) ; NEW_LINE build ( 2 * node + 1 , mid + 1 , end , arr , k ) ; NEW_LINE tree [ node ] = ( tree [ 2 * node ] * tree [ 2 * node + 1 ] ) % k ; NEW_LINE DEDENT