#include <bits/stdc++.h>
using namespace std;
const double Pi = acos(-1.0);
inline int cmp(double x, double y = 0, double tol = 1e-7) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
struct point {
  double x, y;
  point(double x = 0, double y = 0) : x(x), y(y) {}
  point operator+(point q) { return point(x + q.x, y + q.y); }
  point operator-(point q) { return point(x - q.x, y - q.y); }
  point operator*(double t) { return point(x * t, y * t); }
  point operator/(double t) { return point(x / t, y / t); }
  double operator*(point q) { return x * q.x + y * q.y; }
  double operator%(point q) { return x * q.y - y * q.x; }
  double polar() { return ((y > -1e-7) ? atan2(y, x) : 2 * Pi + atan2(y, x)); }
  double mod() { return sqrt(x * x + y * y); }
  double mod2() { return (x * x + y * y); }
  point rotate(double t) {
    return point(x * cos(t) - y * sin(t), x * sin(t) + y * cos(t));
  }
  point rotate(double sin, double cos) {
    return point(x * cos - y * sin, x * sin + y * cos);
  }
  int cmp(point q) const {
    if (int t = ::cmp(x, q.x)) return t;
    return ::cmp(y, q.y);
  }
  bool operator==(point q) const { return cmp(q) == 0; }
  bool operator!=(point q) const { return cmp(q) != 0; }
  bool operator<(point q) const { return cmp(q) < 0; }
  static point pivot;
};
point point::pivot;
double abs(point p) { return hypot(p.x, p.y); }
double arg(point p) { return atan2(p.y, p.x); }
inline int ccw(point p, point q, point r) { return cmp((p - r) % (q - r)); }
point proj(point v, point u) { return u * ((u * v) / (u * u)); }
inline double angle(point p, point q, point r) {
  point u = p - q, v = r - q;
  return atan2(u % v, u * v);
}
bool between(point p, point q, point r) {
  return ccw(p, q, r) == 0 && cmp((p - q) * (r - q)) <= 0;
}
bool seg_intersect(point p, point q, point r, point s) {
  point A = q - p, B = s - r, C = r - p, D = s - q;
  int a = cmp(A % C) + 2 * cmp(A % D);
  int b = cmp(B % C) + 2 * cmp(B % D);
  if (a == 3 || a == -3 || b == 3 || b == -3) return false;
  if (a || b || p == r || p == s || q == r || q == s) return true;
  int t = (p < r) + (p < s) + (q < r) + (q < s);
  return t != 0 && t != 4;
}
double seg_distance(point p, point q, point r) {
  point A = r - q, B = r - p, C = q - p;
  double a = A * A, b = B * B, c = C * C;
  if (cmp(b, a + c) >= 0)
    return sqrt(a);
  else if (cmp(a, b + c) >= 0)
    return sqrt(b);
  else
    return fabs(A % B) / sqrt(c);
}
int in_poly(point p, vector<point>& T) {
  double a = 0;
  int N = T.size();
  for (int i = 0; i < N; i++) {
    if (between(T[i], p, T[(i + 1) % N])) return -1;
    a += angle(T[i], p, T[(i + 1) % N]);
  }
  return cmp(a) != 0;
}
bool radial_lt(point p, point q) {
  point P = p - point::pivot, Q = q - point::pivot;
  double R = P % Q;
  if (cmp(R)) return R > 0;
  return cmp(P * P, Q * Q) < 0;
}
vector<point> convex_hull(vector<point>& T) {
  int j = 0, k, n = T.size();
  vector<point> U(n);
  point::pivot = *min_element((T).begin(), (T).end());
  sort((T).begin(), (T).end(), radial_lt);
  for (k = n - 2; k >= 0 && ccw(T[0], T[n - 1], T[k]) == 0; k--)
    ;
  reverse((k + 1) + (T).begin(), (T).end());
  for (int i = 0; i < n; i++) {
    while (j > 1 && ccw(U[j - 1], U[j - 2], T[i]) >= 0) j--;
    U[j++] = T[i];
  }
  U.erase(j + (U).begin(), (U).end());
  return U;
}
point line_intersect(point p, point q, point r, point s) {
  point a = q - p, b = s - r, c = point(p % q, r % s);
  return point(point(a.x, b.x) % c, point(a.y, b.y) % c) / (a % b);
}
double poly_area(vector<point>& T) {
  double s = 0;
  int n = T.size();
  for (int i = 0; i < n; i++) s += T[i] % T[(i + 1) % n];
  return s / 2;
}
struct segment {
  point a, b;
  segment(point a = point(0, 0), point b = point(0, 0)) : a(a), b(b) {}
  void input() {
    cin >> a.x >> a.y >> b.x >> b.y;
    if (b < a) swap(a, b);
  }
  void output() {
    printf("a=(%.1f  %.1f)  b=(%.1f  %.1f)\n", a.x, a.y, b.x, b.y);
  }
  bool operator<(const segment& q) const {
    return a < q.a || (a == q.a && b < q.b);
  }
};
bool solve(segment s[4]) {
  if (s[0].a != s[1].a) return false;
  if (s[0].b != s[2].a) return false;
  if (s[1].b != s[3].a) return false;
  if (s[2].b != s[3].b) return false;
  if (cmp(s[0].a.x, s[0].b.x) != 0) return false;
  if (cmp(s[1].a.y, s[1].b.y) != 0) return false;
  if (cmp(s[2].a.y, s[2].b.y) != 0) return false;
  if (cmp(s[3].a.x, s[3].b.x) != 0) return false;
  if (s[0].a == s[0].b) return false;
  if (s[1].a == s[1].b) return false;
  return true;
}
int main() {
  segment s[4];
  for (int i = 0; i < 4; i++) {
    s[i].input();
  }
  sort(s, s + 4);
  printf("%s\n", (solve(s) ? "YES" : "NO"));
  return 0;
}

### Prompt

Generate 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 double Pi = acos(-1.0);
inline int cmp(double x, double y = 0, double tol = 1e-7) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
struct point {
  double x, y;
  point(double x = 0, double y = 0) : x(x), y(y) {}
  point operator+(point q) { return point(x + q.x, y + q.y); }
  point operator-(point q) { return point(x - q.x, y - q.y); }
  point operator*(double t) { return point(x * t, y * t); }
  point operator/(double t) { return point(x / t, y / t); }
  double operator*(point q) { return x * q.x + y * q.y; }
  double operator%(point q) { return x * q.y - y * q.x; }
  double polar() { return ((y > -1e-7) ? atan2(y, x) : 2 * Pi + atan2(y, x)); }
  double mod() { return sqrt(x * x + y * y); }
  double mod2() { return (x * x + y * y); }
  point rotate(double t) {
    return point(x * cos(t) - y * sin(t), x * sin(t) + y * cos(t));
  }
  point rotate(double sin, double cos) {
    return point(x * cos - y * sin, x * sin + y * cos);
  }
  int cmp(point q) const {
    if (int t = ::cmp(x, q.x)) return t;
    return ::cmp(y, q.y);
  }
  bool operator==(point q) const { return cmp(q) == 0; }
  bool operator!=(point q) const { return cmp(q) != 0; }
  bool operator<(point q) const { return cmp(q) < 0; }
  static point pivot;
};
point point::pivot;
double abs(point p) { return hypot(p.x, p.y); }
double arg(point p) { return atan2(p.y, p.x); }
inline int ccw(point p, point q, point r) { return cmp((p - r) % (q - r)); }
point proj(point v, point u) { return u * ((u * v) / (u * u)); }
inline double angle(point p, point q, point r) {
  point u = p - q, v = r - q;
  return atan2(u % v, u * v);
}
bool between(point p, point q, point r) {
  return ccw(p, q, r) == 0 && cmp((p - q) * (r - q)) <= 0;
}
bool seg_intersect(point p, point q, point r, point s) {
  point A = q - p, B = s - r, C = r - p, D = s - q;
  int a = cmp(A % C) + 2 * cmp(A % D);
  int b = cmp(B % C) + 2 * cmp(B % D);
  if (a == 3 || a == -3 || b == 3 || b == -3) return false;
  if (a || b || p == r || p == s || q == r || q == s) return true;
  int t = (p < r) + (p < s) + (q < r) + (q < s);
  return t != 0 && t != 4;
}
double seg_distance(point p, point q, point r) {
  point A = r - q, B = r - p, C = q - p;
  double a = A * A, b = B * B, c = C * C;
  if (cmp(b, a + c) >= 0)
    return sqrt(a);
  else if (cmp(a, b + c) >= 0)
    return sqrt(b);
  else
    return fabs(A % B) / sqrt(c);
}
int in_poly(point p, vector<point>& T) {
  double a = 0;
  int N = T.size();
  for (int i = 0; i < N; i++) {
    if (between(T[i], p, T[(i + 1) % N])) return -1;
    a += angle(T[i], p, T[(i + 1) % N]);
  }
  return cmp(a) != 0;
}
bool radial_lt(point p, point q) {
  point P = p - point::pivot, Q = q - point::pivot;
  double R = P % Q;
  if (cmp(R)) return R > 0;
  return cmp(P * P, Q * Q) < 0;
}
vector<point> convex_hull(vector<point>& T) {
  int j = 0, k, n = T.size();
  vector<point> U(n);
  point::pivot = *min_element((T).begin(), (T).end());
  sort((T).begin(), (T).end(), radial_lt);
  for (k = n - 2; k >= 0 && ccw(T[0], T[n - 1], T[k]) == 0; k--)
    ;
  reverse((k + 1) + (T).begin(), (T).end());
  for (int i = 0; i < n; i++) {
    while (j > 1 && ccw(U[j - 1], U[j - 2], T[i]) >= 0) j--;
    U[j++] = T[i];
  }
  U.erase(j + (U).begin(), (U).end());
  return U;
}
point line_intersect(point p, point q, point r, point s) {
  point a = q - p, b = s - r, c = point(p % q, r % s);
  return point(point(a.x, b.x) % c, point(a.y, b.y) % c) / (a % b);
}
double poly_area(vector<point>& T) {
  double s = 0;
  int n = T.size();
  for (int i = 0; i < n; i++) s += T[i] % T[(i + 1) % n];
  return s / 2;
}
struct segment {
  point a, b;
  segment(point a = point(0, 0), point b = point(0, 0)) : a(a), b(b) {}
  void input() {
    cin >> a.x >> a.y >> b.x >> b.y;
    if (b < a) swap(a, b);
  }
  void output() {
    printf("a=(%.1f  %.1f)  b=(%.1f  %.1f)\n", a.x, a.y, b.x, b.y);
  }
  bool operator<(const segment& q) const {
    return a < q.a || (a == q.a && b < q.b);
  }
};
bool solve(segment s[4]) {
  if (s[0].a != s[1].a) return false;
  if (s[0].b != s[2].a) return false;
  if (s[1].b != s[3].a) return false;
  if (s[2].b != s[3].b) return false;
  if (cmp(s[0].a.x, s[0].b.x) != 0) return false;
  if (cmp(s[1].a.y, s[1].b.y) != 0) return false;
  if (cmp(s[2].a.y, s[2].b.y) != 0) return false;
  if (cmp(s[3].a.x, s[3].b.x) != 0) return false;
  if (s[0].a == s[0].b) return false;
  if (s[1].a == s[1].b) return false;
  return true;
}
int main() {
  segment s[4];
  for (int i = 0; i < 4; i++) {
    s[i].input();
  }
  sort(s, s + 4);
  printf("%s\n", (solve(s) ? "YES" : "NO"));
  return 0;
}

```