#include #ifdef BUG #include "debug.hpp" #else #define DEBUG(var) #endif using namespace std; template< class T1, class T2 > inline istream & operator>>( istream & fin, pair< T1, T2 > & pr ) { fin >> pr.first >> pr.second; return fin; } template< class T0, class T1, class T2 > inline istream & operator>>( istream & fin, tuple< T0, T1, T2 > & t ) { fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; } template< class T > inline istream & operator>>( istream & fin, vector< T > & a ) { for(auto & u: a) fin >> u; return fin; } template inline istream & operator>>( istream & fin, array & a ) { for(auto & u: a) fin >> u; return fin; } template inline auto dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void { typedef typename iterator_traits::value_type value_type; copy(first, last, ostream_iterator(cout, dlm)); } template vector & operator--(vector & a) { for(auto & i: a) --i; return a; } /* @@@ ----------------------------------- */ typedef struct { int64_t x, y; } point_t; inline bool comp_angle(const point_t & a, const point_t & b) { const bool ia = 0 < a.y || (a.y == 0 && 0 < a.x); const bool ib = 0 < b.y || (b.y == 0 && 0 < b.x); if(ia != ib) return ia; // if a makes an obtuse angele w/ 90 degree rotated b return a.y * b.x < a.x * b.y; } const char * points_on_a_rectangle() { size_t n; cin >> n; vector> a(n); cin >> a; sort(begin(a), end(a)); a.erase(unique(begin(a), end(a)), end(a)); n = a.size(); if(n < 4) return "YES"; do { bool fail = false; size_t cnt = 0; for(size_t j = 0; j < n && !fail; ++j) { const size_t i = j ? j - 1 : n - 1; const size_t k = (j + 1) % n; const point_t s = {a[j].first - a[i].first, a[j].second - a[i].second}; const point_t t = {a[k].first - a[j].first, a[k].second - a[j].second}; const auto val = s.x * t.x + s.y * t.y; cnt += s.x * t.x + s.y * t.y == 0; fail = fail || (val && (comp_angle(s, t) || comp_angle(t, s))); } fail = fail || 4 < cnt; if(!fail) { DEBUG(a); return "YES"; } } while(next_permutation(begin(a) + 1, end(a))); return "NO"; } int main(const int argc, char * argv []) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); size_t q; for(cin >> q; q; --q) cout << points_on_a_rectangle() << '\n'; return EXIT_SUCCESS; }