#include #include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n , q ,a,b; set x,y; cin >> q; while(q--) { cin >> n; while(n--) { cin >> a >> b; x.insert(a); y.insert(b); } if(x.size() > 2 && y.size() > 2) { cout << "NO\n"; x.clear(); y.clear(); continue; } else { cout << "YES\n"; x.clear(); y.clear(); } } return 0; }