#include #include #include #include #include #include int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int q; //!< number of queries std::cin >> q; for (int i = 0; i < q; ++i) { int n; //!< number of points std::cin >> n; int x_min = INT_MIN; int x_max = INT_MAX; int y_min = INT_MIN; int y_max = INT_MAX; bool al_rect = true; for (int j = 0; j < n; ++j) { int x, y; std::cin >> x >> y; if ((x != x_min) && (x != x_max)) { if (INT_MIN == x_min) x_min = x; else if (INT_MAX == x_max) { x_max = x; } else { al_rect = false; break; } } if ((y != y_min) && (y != y_max)) { if (INT_MIN == y_min) y_min = y; else if (INT_MAX == y_max) { y_max = y; } else { al_rect = false; break; } } } if (true == al_rect) std::cout << "YES" << std::endl; else std::cout << "NO" << std::endl; } return 0; }