Function to find the maximum element of the set which belongs to the element queries [ i ]
void findMaxValueOfSet ( vector < pair < int , int > > & arr , vector < int > & queries , int R , int N , int M ) {