#include #include #include #include #include using namespace std; struct Point { int x, y; }; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ const int N = 10; int q, n; Point p[N]; string result; cin >> q; for (int qi = 0; qi < q; qi++) { cin >> n; for (int ni = 0; ni < n; ni++) { cin >> p[ni].x >> p[ni].y; } result = "YES"; for (int i = 0; i < n; i++) { Point p0 = p[i]; int j; for (j = 0; j < n; j++) { if (j == i) continue; if (p0.x == p[j].x || p0.y == p[j].y) { // point ok break; } } if (j == n) { result = "NO"; break; } } cout << result << endl; } return 0; }