#include <bits/stdc++.h>
using namespace std;
struct rect {
  int x1, y1, x2, y2;
};
int main() {
  int n;
  cin >> n;
  vector<rect> v;
  for (int i = 0; i < n; i++) {
    rect r;
    cin >> r.x1 >> r.y1 >> r.x2 >> r.y2;
    v.push_back(r);
  }
  set<pair<int, int> > p;
  for (int i = 0; i < n; i++) {
    rect r = v[i];
    pair<int, int> p1 = make_pair(r.x1, r.y1);
    pair<int, int> p2 = make_pair(r.x1, r.y2);
    pair<int, int> p3 = make_pair(r.x2, r.y1);
    pair<int, int> p4 = make_pair(r.x2, r.y2);
    if (p.find(p1) != p.end())
      p.erase(p1);
    else
      p.insert(p1);
    if (p.find(p2) != p.end())
      p.erase(p2);
    else
      p.insert(p2);
    if (p.find(p3) != p.end())
      p.erase(p3);
    else
      p.insert(p3);
    if (p.find(p4) != p.end())
      p.erase(p4);
    else
      p.insert(p4);
  }
  if (p.size() == 4) {
    pair<int, int> p1 = *p.begin();
    pair<int, int> p2 = *p.rbegin();
    if (abs(p1.first - p2.first) == abs(p1.second - p2.second)) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}
