#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int q; // Number of queries cin >> q; for (int thisQ = 1; thisQ <= q; thisQ++) { int n; // Number of points >= 1 cin >> n; // Rectangle boundaries; int minX, minY; int maxX, maxY; vector pointX(n), pointY(n); bool stillGood = true; cin >> pointX[0] >> pointY[0]; minX = pointX[0]; maxX = minX; minY = pointY[0]; maxY = minY; // Find the rectangle boundaries. for (int thisPoint = 1; thisPoint < n; thisPoint++) { cin >> pointX[thisPoint] >> pointY[thisPoint]; if (pointX[thisPoint] < minX) minX = pointX[thisPoint]; else if (pointX[thisPoint] > maxX) maxX = pointX[thisPoint]; if (pointY[thisPoint] < minY) minY = pointY[thisPoint]; else if (pointY[thisPoint] > maxY) maxY = pointY[thisPoint]; } // Check that all points are on a boundary. for (int thisPoint = 0; thisPoint < n; thisPoint++) { if ((pointX[thisPoint] != minX) && (pointX[thisPoint] != maxX) && (pointY[thisPoint] != minY) && (pointY[thisPoint] != maxY)) { stillGood = false; break; } } if (stillGood) cout << "YES\n"; else cout << "NO\n"; } return 0; }