#include #include #include #include #include using namespace std; const int C = (int)1e5; const int N = 20; int n; int a[N][2]; int x[N], y[N]; bool solve() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &a[i][0], &a[i][1]); x[i] = a[i][0]; y[i] = a[i][1]; } x[n] = y[n] = -C; x[n + 1] = y[n + 1] = C; sort(x, x + n + 2); sort(y, y + n + 2); int xSz = unique(x, x + n + 2) - x; int ySz = unique(y, y + n + 2) - y; for (int i = 0; i < xSz; i++) for (int j = i + 1; j < xSz; j++) for (int k = 0; k < ySz; k++) for (int h = k + 1; h < ySz; h++) { bool ok = true; for (int it = 0; it < n; it++) { ok &= x[i] <= a[it][0] && a[it][0] <= x[j] && y[k] <= a[it][1] && a[it][1] <= y[h]; ok &= (a[it][0] == x[i] || a[it][0] == x[j] || a[it][1] == y[k] || a[it][1] == y[h]); } if (ok) return true; } return false; } int main() { int t; scanf("%d", &t); while(t--) { if (solve()) printf("YES\n"); else printf("NO\n"); } return 0; }