#include #include #include #include #include using namespace std; class Point { public: int m_x; int m_y; public: Point( int x, int y ) { m_x = x; m_y = y; } }; bool myComp( Point* x, Point* y ) { return x->m_x < y->m_x || ( x->m_x == y->m_x && x->m_y < y->m_y ); } bool myComp2( Point* x, Point* y ) { return x->m_y < y->m_y || ( x->m_y == y->m_y && x->m_x < y->m_x ); } int main() { int Q; cin >> Q; for( int query=0 ; query points; int n; cin >> n; for( int i=0 ; i> a >> b; points.push_back( new Point( a, b ) ); } sort( points.begin(), points.end(), myComp ); int left = points[0]->m_x; int right = points[n-1]->m_x; sort( points.begin(), points.end(), myComp2 ); int top = points[n-1]->m_y; int bottom = points[0]->m_y; bool OK = true; for( int i=0 ; im_x != left && points[i]->m_x != right && points[i]->m_y != top && points[i]->m_y != bottom ) { OK = false; cout << "NO" << endl; break; } } if( OK ) cout << "YES" << endl; points.clear(); } return 0; }