#include #include #include #include #include #include using namespace std; int main() { int T; scanf("%d", &T); while(T--){ int N; scanf("%d", &N); pair A[20]; int X[20], Y[20]; for(int i=1; i<=N; ++i){ scanf("%d %d", &A[i].first, &A[i].second); X[i] = A[i].first, Y[i] = A[i].second; } sort(X + 1, X + N + 1); sort(Y + 1, Y + N + 1); int x0 = X[1], x1 = X[N], y0 = Y[1], y1 = Y[N]; bool ok = true; for(int i=1; i<=N; ++i){ int xx = A[i].first, yy = A[i].second; if((x0 <= xx && xx <= x1 && (yy == y0 || yy == y1)) || (y0 <= yy && yy <= y1 && (xx == x0 || xx == x1))) continue; else{ ok = false; break; } } printf("%s\n", ok ? "YES" : "NO"); } return 0; }