Vectors to store maximum and minimum of all the four forms
vector < int > V ( N ) , V1 ( N ) ; for ( int i = 0 ; i < N ; i ++ ) { V [ i ] = A [ i ] . first + A [ i ] . second ; V1 [ i ] = A [ i ] . first - A [ i ] . second ; }