#include #include #include #include #include using namespace std; typedef long double ld; typedef pair ii; typedef pair ldld; const ld eps = 1e-11l; const int Inf = 1000000000; int q; int n; vector cur; bool Check(vector &V) { ld curX = 1e30, curY = 1e30; for (int i = 0; i < n; i++) { if (fabs(V[i].first) >= eps) if (curX == 1e30 || fabs(V[i].first - curX) < eps) curX = V[i].first; else return false; if (fabs(V[i].second) >= eps) if (curY == 1e30 || fabs(V[i].second - curY) < eps) curY = V[i].second; else return false; } return true; } ldld Rot(ldld cur, ld ang) { ldld nw; nw.first = cos(ang) * cur.first + sin(ang) * cur.second; nw.second = -sin(ang) * cur.first + cos(ang) * cur.second; return nw; } bool Solve() { for (int i = 0; i < cur.size(); i++) for (int j = i + 1; j < cur.size(); j++) { ld ang = atan2(ld(cur[j].second - cur[i].second), ld(cur[j].first - cur[i].first)); vector V; for (int z = 0; z < cur.size(); z++) { ldld my = ldld(cur[z].first - cur[i].first, cur[z].second - cur[i].second); V.push_back(Rot(my, ang)); } if (Check(V)) return true; } return false; } int main() { scanf("%d", &q); while (q--) { scanf("%d", &n); cur.resize(n); for (int i = 0; i < n; i++) cin >> cur[i].first >> cur[i].second; sort(cur.begin(), cur.end()); cur.erase(unique(cur.begin(), cur.end()), cur.end()); n = cur.size(); int mnx = Inf, mxx = -Inf, mny = Inf, mxy = -Inf; for (int i = 0; i < n; i++) { mnx = min(mnx, cur[i].first); mxx = max(mxx, cur[i].first); mny = min(mny, cur[i].second); mxy = max(mxy, cur[i].second); } bool ok = true; for (int i = 0; i < n && ok; i++) ok = cur[i].first == mnx || cur[i].first == mxx || cur[i].second == mny || cur[i].second == mxy; printf("%s\n", ok? "YES": "NO"); /*if (n <= 4) printf("YES\n"); else printf("%s\n", Solve()? "YES": "NO");*/ } return 0; }