#include <bits/stdc++.h>
using namespace std;
struct country {
  int a, b, c, d;
  country() { a = b = c = d = 0; };
};
void print(vector<country> cur, vector<country> l, vector<country> r) {
  cout << "*******************" << endl;
  for (int i = 0; i < cur.size(); i++)
    printf("%d %d %d %d\n", cur[i].a, cur[i].b, cur[i].c, cur[i].d);
  cout << "->L" << endl;
  for (int i = 0; i < l.size(); i++)
    printf("%d %d %d %d\n", l[i].a, l[i].b, l[i].c, l[i].d);
  cout << "->R" << endl;
  for (int i = 0; i < r.size(); i++)
    printf("%d %d %d %d\n", r[i].a, r[i].b, r[i].c, r[i].d);
}
bool check1(vector<country> &Cur, vector<country> &l, vector<country> &r) {
  vector<pair<int, int> > a;
  for (int i = 0; i < Cur.size(); i++)
    a.push_back(make_pair(Cur[i].a, 1)), a.push_back(make_pair(Cur[i].c, -1));
  sort(a.begin(), a.end());
  int cur = 0, ans = -1;
  for (int i = 0; i < a.size() - 1; i++) {
    cur += a[i].second;
    if (cur == 0) ans = a[i].first;
  }
  if (ans == -1) return 0;
  for (int i = 0; i < Cur.size(); i++) {
    if (Cur[i].c <= ans) l.push_back(Cur[i]);
    if (Cur[i].a >= ans) r.push_back(Cur[i]);
  }
  return 1;
}
bool check2(vector<country> &Cur, vector<country> &l, vector<country> &r) {
  vector<pair<int, int> > a;
  for (int i = 0; i < Cur.size(); i++)
    a.push_back(make_pair(Cur[i].b, 1)), a.push_back(make_pair(Cur[i].d, -1));
  sort(a.begin(), a.end());
  int cur = 0, ans = -1;
  for (int i = 0; i < a.size() - 1; i++) {
    cur += a[i].second;
    if (cur == 0) ans = a[i].first;
  }
  if (ans == -1) return 0;
  for (int i = 0; i < Cur.size(); i++) {
    if (Cur[i].d <= ans) l.push_back(Cur[i]);
    if (Cur[i].b >= ans) r.push_back(Cur[i]);
  }
  return 1;
}
bool check(vector<country> cur) {
  if (cur.size() <= 1) return 1;
  vector<country> l, r;
  if (check1(cur, l, r)) return check(l) && check(r);
  if (check2(cur, l, r)) return check(l) && check(r);
  return 0;
}
int main() {
  int n;
  cin >> n;
  vector<country> tmp;
  for (int i = 1; i <= n; i++) {
    country x;
    scanf("%d%d%d%d", &x.a, &x.b, &x.c, &x.d);
    tmp.push_back(x);
  }
  if (check(tmp))
    puts("YES");
  else
    puts("NO");
  return 0;
}
