Function To find the required interval
static void solve ( int [ , ] interval , int N , int Q ) { int [ ] Mark = new int [ Q ] ; for ( int i = 0 ; i < N ; i ++ ) { int l = interval [ i , 0 ] - 1 ; int r = interval [ i , 1 ] - 1 ; for ( int j = l ; j <= r ; j ++ ) Mark [ j ] ++ ; }