#pragma GCC optimize ("-O3") #define _GLIBCXX_USE_CXX11_ABI 0 #include #define FOR(i, n) for(lli i = 0; i < (lli)(n); ++i) #define FORU(i, j, k) for(lli i = (j); i <= (lli)(k); ++i) #define FORD(i, j, k) for(lli i = (j); i >= (lli)(k); --i) #define DESTRUCT2(t, x, y) \ auto x = get<0>(t); \ auto y = get<1>(t); #define DESTRUCT3(t, x, y, z) \ auto x = get<0>(t); \ auto y = get<1>(t); \ auto z = get<2>(t); #define DESTRUCT4(t, x, y, z, w) \ auto x = get<0>(t); \ auto y = get<1>(t); \ auto z = get<2>(t); \ auto w = get<3>(t); #define SQ(x) ((x)*(x)) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define mp make_pair #define mt make_tuple #define pb push_back #define eb emplace_back #define PE flush << "\033[2K\r" using namespace std; using lli = long long int; using llu = long long unsigned; using pii = tuple; using piii = tuple; using piiii = tuple; using vi = vector; using vii = vector; using viii = vector; using vvi = vector; using vvii = vector; using vviii = vector; template using min_queue = priority_queue, greater >; template using max_queue = priority_queue; template struct my_index_sequence { using type = my_index_sequence; static constexpr array value = { I... }; }; namespace my_index_sequence_detail { template struct concat; template struct concat, my_index_sequence > : my_index_sequence { }; template struct make_index_sequence : concat::type, typename make_index_sequence::type>::type { }; template <> struct make_index_sequence<0> : my_index_sequence<>{}; template <> struct make_index_sequence<1> : my_index_sequence<0>{}; } template using my_index_sequence_for = typename my_index_sequence_detail::make_index_sequence::type; template void print_tuple(ostream& s, T const& a, my_index_sequence){ using swallow = int[]; (void)swallow{0, (void(s << (I == 0? "" : ", ") << get(a)), 0)...}; } template ostream& print_collection(ostream& s, T const& a){ s << '['; for(auto it = begin(a); it != end(a); ++it){ s << *it; if(it != prev(end(a))) s << " "; } return s << ']'; } template ostream& operator<<(ostream& s, tuple const& a){ s << '('; print_tuple(s, a, my_index_sequence_for{}); return s << ')'; } template ostream& operator<<(ostream& s, pair const& a){ return s << "(" << get<0>(a) << ", " << get<1>(a) << ")"; } template ostream& operator<<(ostream& s, array const& a) { return print_collection(s, a); } template ostream& operator<<(ostream& s, vector const& a) { return print_collection(s, a); } template ostream& operator<<(ostream& s, multimap const& a) { return print_collection(s, a); } template ostream& operator<<(ostream& s, multiset const& a) { return print_collection(s, a); } template ostream& operator<<(ostream& s, map const& a) { return print_collection(s, a); } template ostream& operator<<(ostream& s, set const& a) { return print_collection(s, a); } namespace std { namespace { template inline void hash_combine(size_t& seed, T const& v) { seed ^= hash()(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); } template ::value - 1> struct HashValueImpl { static void apply(size_t& seed, Tuple const& tuple) { HashValueImpl::apply(seed, tuple); hash_combine(seed, get(tuple)); } }; template struct HashValueImpl { static void apply(size_t& seed, Tuple const& tuple) { hash_combine(seed, get<0>(tuple)); } }; } template struct hash> { size_t operator()(tuple const& tt) const { size_t seed = 0; HashValueImpl >::apply(seed, tt); return seed; } }; } //------------------------------------------------------------------------------ int main(int, char**){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; set X, Y; FOR(i, n) { int x, y; cin >> x >> y; X.insert(x); Y.insert(y); } cout << ((X.size()==1||Y.size()==1)?"YES":"NO") << endl; return 0; }