#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
bool doubleEqual(long double a, long double b) { return fabs(a - b) < EPS; }
bool doubleLessOrEqual(long double a, long double b) {
  return doubleEqual(a, b) || a < b;
}
bool doubleLess(long double a, long double b) {
  return !doubleEqual(a, b) && a < b;
}
bool doubleGreaterOrEqual(long double a, long double b) {
  return a > b || doubleEqual(a, b);
}
bool doubleGreater(long double a, long double b) {
  return a > b && !doubleEqual(a, b);
}
long double mySqrt(long double a) {
  if (a < 0) {
    return 0;
  }
  return sqrt(a);
}
long double sqr(long double a) { return a * a; }
struct Point {
  long double x, y;
  Point() : x(0), y(0) {}
  Point(long double x, long double y) : x(x), y(y) {}
  Point operator-(const Point &p) const { return {x - p.x, y - p.y}; }
  Point operator+(const Point &p) const { return {x + p.x, y + p.x}; }
  Point &operator+=(const Point &p) {
    x += p.x, y += p.y;
    return *this;
  }
  long double operator%(const Point &p) const { return x * p.x + y * p.y; }
  long double operator*(const Point &p) const { return x * p.y - p.x * y; }
  Point operator/(long double k) const { return {x / k, y / k}; }
  Point &operator/=(long double k) {
    x /= k;
    y /= k;
    return *this;
  }
  bool operator<(const Point &p) const {
    return x < p.x || (x == p.x && y < p.y);
  }
  Point operator*(long double k) const { return {x * k, y * k}; }
  Point &operator*=(long double k) {
    x *= k, y *= k;
    return *this;
  }
  long double length() const { return mySqrt(*this % *this); }
  long double distTo(const Point &p) const { return (*this - p).length(); }
  long double distTo(const Point &A, const Point &B) const {
    long double d = A.distTo(B);
    long double s = (*this - A) * (*this - B);
    return fabs(s) / d;
  }
  Point normalize(long double k = 1.0) const {
    long double len = length();
    return *this * (k / len);
  }
  Point getH(const Point &A, const Point &B) const {
    Point C = *this;
    Point v = B - A;
    Point u = C - A;
    long double k = v % u / v.length();
    v = v.normalize(k);
    Point H = A + v;
    return H;
  }
  Point rotate() const { return {-y, x}; }
  Point rotate(long double alpha) const {
    Point v = *this;
    Point w;
    w.x = v.x * cos(alpha) - v.y * sin(alpha);
    w.y = v.x * sin(alpha) + v.y * cos(alpha);
    return w;
  }
  bool isOnLine(const Point &A, const Point &B) const {
    return doubleEqual((*this - A) * (*this - B), 0.0);
  }
  bool isInSegment(const Point &A, const Point &B) const {
    return isOnLine(A, B) && doubleLessOrEqual((A - *this) % (B - *this), 0);
  }
  bool isInSegmentStrictly(const Point &A, const Point &B) const {
    return isOnLine(A, B) && doubleLess((A - *this) % (B - *this), 0);
  }
  long double getAngle() { return atan2(y, x); }
  long double getAngle(const Point &p) const {
    return atan2(p * *this, p % *this);
  }
};
int getTangent(const Point &A, const Point &O, long double r, Point &M,
               Point &N) {
  Point v = O - A;
  long double d = v.length();
  long double alpha = asin(r / d);
  long double L = mySqrt(sqr(d) - sqr(r));
  v = v.normalize(L);
  M = A + v.rotate(alpha);
  N = A + v.rotate(-alpha);
  if (doubleEqual(r, d)) return 1;
  return 2;
}
istream &operator>>(istream &in, Point &A) {
  in >> A.x >> A.y;
  return in;
}
ostream &operator<<(ostream &in, Point &A) {
  in << A.x << A.y;
  return in;
}
Point O;
bool cmp(const Point &A, const Point &B) {
  return (A - O) * (B - O) < 0 ||
         ((A - O) * (B - O) == 0 && (A - O).length() < (B - O).length());
}
vector<Point> convexHull(vector<Point> &a) {
  vector<Point> convex;
  convex.push_back(O);
  for (int i = 1; i < a.size(); ++i) {
    Point A = convex.back() - convex[convex.size() - 2],
          B = a[i] - convex.back();
    long double k = A * B;
    while (convex.size() > 1 && ((convex.back() - convex[convex.size() - 2]) *
                                     (a[i] - convex.back()) >=
                                 0)) {
      convex.pop_back();
    }
    convex.push_back(a[i]);
  }
  return convex;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Point A, B, C, D, E, F, G, H;
  cin >> A >> B >> C >> D >> E >> F >> G >> H;
  set<Point> q;
  map<pair<Point, Point>, bool> was;
  was[{A, B}] = 1;
  was[{C, D}] = 1;
  was[{E, F}] = 1;
  was[{G, H}] = 1;
  q.insert(A);
  q.insert(B);
  q.insert(C);
  q.insert(D);
  q.insert(E);
  q.insert(F);
  q.insert(G);
  q.insert(H);
  if (q.size() != 4) {
    cout << "NO\n";
    return 0;
  }
  vector<Point> pts;
  for (auto x : q) {
    pts.push_back(x);
  }
  Point O1;
  long double sq = 0;
  sort(pts.begin(), pts.end());
  O = pts[0];
  sort(pts.begin() + 1, pts.end(), cmp);
  pts = convexHull(pts);
  for (int i = 0; i < 4; ++i) {
    int next = (i + 1) % 4;
    sq += (pts[i] - O1) * (pts[next] - O1);
    if (!was[{pts[i], pts[next]}] && !was[{pts[next], pts[i]}]) {
      cout << "NO\n";
      return 0;
    }
  }
  sq = abs(sq) / 2;
  long double sq1 = pts[0].distTo(pts[1]) * pts[0].distTo(pts[3]);
  if (sq == sq1) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}

### Prompt

Your task is to create a CPP solution to the following problem:

Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the program detects if the four given segments form a rectangle of a positive area and with sides parallel to coordinate axes. As Alex does badly at school and can't write this program by himself, he asks you to help him.

Input

The input data contain four lines. Each of these lines contains four integers x1, y1, x2, y2 ( - 109 ≤ x1, y1, x2, y2 ≤ 109) — coordinates of segment's beginning and end positions. The given segments can degenerate into points.

Output

Output the word «YES», if the given four segments form the required rectangle, otherwise output «NO».

Examples

Input

1 1 6 1
1 0 6 0
6 0 6 1
1 1 1 0


Output

YES


Input

0 0 0 3
2 0 0 0
2 2 2 0
0 2 2 2


Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
bool doubleEqual(long double a, long double b) { return fabs(a - b) < EPS; }
bool doubleLessOrEqual(long double a, long double b) {
  return doubleEqual(a, b) || a < b;
}
bool doubleLess(long double a, long double b) {
  return !doubleEqual(a, b) && a < b;
}
bool doubleGreaterOrEqual(long double a, long double b) {
  return a > b || doubleEqual(a, b);
}
bool doubleGreater(long double a, long double b) {
  return a > b && !doubleEqual(a, b);
}
long double mySqrt(long double a) {
  if (a < 0) {
    return 0;
  }
  return sqrt(a);
}
long double sqr(long double a) { return a * a; }
struct Point {
  long double x, y;
  Point() : x(0), y(0) {}
  Point(long double x, long double y) : x(x), y(y) {}
  Point operator-(const Point &p) const { return {x - p.x, y - p.y}; }
  Point operator+(const Point &p) const { return {x + p.x, y + p.x}; }
  Point &operator+=(const Point &p) {
    x += p.x, y += p.y;
    return *this;
  }
  long double operator%(const Point &p) const { return x * p.x + y * p.y; }
  long double operator*(const Point &p) const { return x * p.y - p.x * y; }
  Point operator/(long double k) const { return {x / k, y / k}; }
  Point &operator/=(long double k) {
    x /= k;
    y /= k;
    return *this;
  }
  bool operator<(const Point &p) const {
    return x < p.x || (x == p.x && y < p.y);
  }
  Point operator*(long double k) const { return {x * k, y * k}; }
  Point &operator*=(long double k) {
    x *= k, y *= k;
    return *this;
  }
  long double length() const { return mySqrt(*this % *this); }
  long double distTo(const Point &p) const { return (*this - p).length(); }
  long double distTo(const Point &A, const Point &B) const {
    long double d = A.distTo(B);
    long double s = (*this - A) * (*this - B);
    return fabs(s) / d;
  }
  Point normalize(long double k = 1.0) const {
    long double len = length();
    return *this * (k / len);
  }
  Point getH(const Point &A, const Point &B) const {
    Point C = *this;
    Point v = B - A;
    Point u = C - A;
    long double k = v % u / v.length();
    v = v.normalize(k);
    Point H = A + v;
    return H;
  }
  Point rotate() const { return {-y, x}; }
  Point rotate(long double alpha) const {
    Point v = *this;
    Point w;
    w.x = v.x * cos(alpha) - v.y * sin(alpha);
    w.y = v.x * sin(alpha) + v.y * cos(alpha);
    return w;
  }
  bool isOnLine(const Point &A, const Point &B) const {
    return doubleEqual((*this - A) * (*this - B), 0.0);
  }
  bool isInSegment(const Point &A, const Point &B) const {
    return isOnLine(A, B) && doubleLessOrEqual((A - *this) % (B - *this), 0);
  }
  bool isInSegmentStrictly(const Point &A, const Point &B) const {
    return isOnLine(A, B) && doubleLess((A - *this) % (B - *this), 0);
  }
  long double getAngle() { return atan2(y, x); }
  long double getAngle(const Point &p) const {
    return atan2(p * *this, p % *this);
  }
};
int getTangent(const Point &A, const Point &O, long double r, Point &M,
               Point &N) {
  Point v = O - A;
  long double d = v.length();
  long double alpha = asin(r / d);
  long double L = mySqrt(sqr(d) - sqr(r));
  v = v.normalize(L);
  M = A + v.rotate(alpha);
  N = A + v.rotate(-alpha);
  if (doubleEqual(r, d)) return 1;
  return 2;
}
istream &operator>>(istream &in, Point &A) {
  in >> A.x >> A.y;
  return in;
}
ostream &operator<<(ostream &in, Point &A) {
  in << A.x << A.y;
  return in;
}
Point O;
bool cmp(const Point &A, const Point &B) {
  return (A - O) * (B - O) < 0 ||
         ((A - O) * (B - O) == 0 && (A - O).length() < (B - O).length());
}
vector<Point> convexHull(vector<Point> &a) {
  vector<Point> convex;
  convex.push_back(O);
  for (int i = 1; i < a.size(); ++i) {
    Point A = convex.back() - convex[convex.size() - 2],
          B = a[i] - convex.back();
    long double k = A * B;
    while (convex.size() > 1 && ((convex.back() - convex[convex.size() - 2]) *
                                     (a[i] - convex.back()) >=
                                 0)) {
      convex.pop_back();
    }
    convex.push_back(a[i]);
  }
  return convex;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Point A, B, C, D, E, F, G, H;
  cin >> A >> B >> C >> D >> E >> F >> G >> H;
  set<Point> q;
  map<pair<Point, Point>, bool> was;
  was[{A, B}] = 1;
  was[{C, D}] = 1;
  was[{E, F}] = 1;
  was[{G, H}] = 1;
  q.insert(A);
  q.insert(B);
  q.insert(C);
  q.insert(D);
  q.insert(E);
  q.insert(F);
  q.insert(G);
  q.insert(H);
  if (q.size() != 4) {
    cout << "NO\n";
    return 0;
  }
  vector<Point> pts;
  for (auto x : q) {
    pts.push_back(x);
  }
  Point O1;
  long double sq = 0;
  sort(pts.begin(), pts.end());
  O = pts[0];
  sort(pts.begin() + 1, pts.end(), cmp);
  pts = convexHull(pts);
  for (int i = 0; i < 4; ++i) {
    int next = (i + 1) % 4;
    sq += (pts[i] - O1) * (pts[next] - O1);
    if (!was[{pts[i], pts[next]}] && !was[{pts[next], pts[i]}]) {
      cout << "NO\n";
      return 0;
    }
  }
  sq = abs(sq) / 2;
  long double sq1 = pts[0].distTo(pts[1]) * pts[0].distTo(pts[3]);
  if (sq == sq1) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}

```