multiset will hold pairs pair = ( log value of product , dp [ j ] value ) dp [ j ] = minimum product % mod multiset will be sorted according to log values Therefore , corresponding to the minimum log value dp [ j ] value can be obtained .
s . append ( [ p [ 0 ] , dp [ 0 ] ] ) ; NEW_LINE s . sort ( ) NEW_LINE