#include #include #include #include #include #include #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define pb push_back #define mp make_pair #define fst first #define snd second #define show(x) cout << #x << " = " << x << endl #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define pii pair #define vi vector using namespace std; template ostream& operator<<(ostream& o, const pair& p) { return o << "(" << p.first << "," << p.second << ")"; } template ostream& operator<<(ostream& o, const vector& vc) { o << "sz = " << vc.size() << endl << "["; for (const T& v : vc) o << v << ","; o << "]"; return o; } typedef long long ll; #define MAX 100 int N; bool check[MAX][MAX]; vector edge[MAX][MAX]; int main() { cin >> N; rep(i, N) { int r0, c0, r1, c1; cin >> r0 >> c0 >> r1 >> c1; r0--, c0--, r1--, c1--; edge[r0][c0].pb(mp(r1, c1)); edge[r1][c1].pb(mp(r0, c0)); } bool f = true; rep(i, MAX) { if (not f) { break; } rep(j, MAX) { if (not check[i][j]) { int v = 0; int e = 0; queue q; q.push(mp(i, j)); check[i][j] = true; while (not q.empty()) { const pii p = q.front(); v++; q.pop(); for (const auto p2 : edge[p.fst][p.snd]) { e++; if (not check[p2.fst][p2.snd]) { q.push(p2); check[p2.fst][p2.snd] = true; } } } e /= 2; // if (e != 0) { // cout << e << " " << v << endl; // } if (e > v) { f = false; break; } } } } if (f) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }