#include #define endl '\n' using namespace std; int tests,current_case; void message(int current_case) { //cerr<<"Case "< mr, mc; //tests=1; scanf("%d", &tests); for(current_case=1;current_case<=tests;current_case++) { scanf("%d", &n); rows=0; cols=0; mr.clear(); mc.clear(); for(i=1;i<=n;i++) { scanf("%d %d", &x, &y); if(mr.find(x)==mr.end()) mr[x]=true,++rows; if(mc.find(y)==mc.end()) mc[y]=true,++cols; } if(rows<=2 && cols<=2) printf("YES\n"); else printf("NO\n"); message(current_case); } return 0; }