// // main.cpp // HackerRank-101Hack42 // // Created by BahadirAltun on 18/10/16. // Copyright © 2016 Bahadir Altun. All rights reserved. // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define mid ((lf + rg) >> 1) #define right (left | 1) #define left (v << 1) typedef pair pii; typedef long long ll; const ll linf = 1e18 + 9; const long long inf = 1e9 + 9; const long long N = 3e5 + 9; int q, n; ll a[N], b[N]; int main() { cin >> q; for (int qq = 1; qq <= q; qq++) { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; int mxx, mnx, mxy, mny; mxx = mnx = mxy = mny = 1; for (int i = 1; i <= n; i++) { if (a[mxx] < a[i]) mxx = i; if (a[mnx] > a[i]) mnx = i; if (b[mxy] < b[i]) mxy = i; if (b[mny] > b[i]) mny = i; } bool flag = 0; for (int i = 1; i <= n; i++) if (a[i] != a[mxx] and a[i] != a[mnx] and b[i] != b[mny] and b[i] != b[mxy]) flag = 1; if (flag) puts("NO"); else puts("YES"); } return 0; }