Function to query product of sub - array [ l . . r ] in O ( log n ) time
ll query ( int node , int start , int end , int l , int r , int k ) { if ( start > end start > r end < l ) { return 1 ; } if ( start >= l && end <= r ) { return tree [ node ] % k ; } int mid = ( start + end ) >> 1 ; ll q1 = query ( 2 * node , start , mid , l , r , k ) ; ll q2 = query ( 2 * node + 1 , mid + 1 , end , l , r , k ) ; return ( q1 * q2 ) % k ; }