#include <bits/stdc++.h>
using namespace std;
inline int lowbit(int x) { return x & (-x); }
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
template <typename A, typename B, typename C>
inline A fpow(A x, B p, C lyd) {
  A ans = 1;
  for (; p; p >>= 1, x = 1LL * x * x % lyd)
    if (p & 1) ans = 1LL * x * ans % lyd;
  return ans;
}
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
template <typename T>
inline T max(T x, T y, T z) {
  return max(max(x, y), z);
}
template <typename T>
inline T min(T x, T y, T z) {
  return min(min(x, y), z);
}
const double PI = acos(-1);
const double eps = 1e-7;
const int maxn = 1e6 + 10;
const long long INF = 0x3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
double dcmp(double x) {
  if (fabs(x) < eps)
    return 0;
  else
    return x < 0 ? -1 : 1;
}
struct Point {
  double x, y;
  Point(double x0 = 0, double y0 = 0) : x(x0), y(y0) {}
  friend bool operator<(Point a, Point b) {
    return a.x != b.x ? a.x < b.x : a.y < b.y;
  }
  friend Point operator+(const Point &a, const Point &b) {
    return Point(a.x + b.x, a.y + b.y);
  }
  friend Point operator-(const Point &a, const Point &b) {
    return Point(a.x - b.x, a.y - b.y);
  }
  friend Point operator*(const Point &a, double b) {
    return Point(a.x * b, a.y * b);
  }
  friend Point operator/(const Point &a, double b) {
    return Point(a.x / b, a.y / b);
  }
  bool operator==(const Point &a) const {
    return dcmp(x - a.x) == 0 && dcmp(y - a.y) == 0;
  }
};
double Dot(const Point &a, const Point &b) { return a.x * b.x + a.y * b.y; }
double Cross(const Point &a, const Point &b) { return a.x * b.y - a.y * b.x; }
Point getLineIntersection(const Point &P, const Point &v, const Point &Q,
                          const Point &w) {
  Point u = P - Q;
  double t = Cross(w, u) / Cross(v, w);
  return P + v * t;
}
bool SegmentProperIntersection(const Point &a1, const Point &b1,
                               const Point &a2, const Point &b2) {
  double c1 = Cross(b1 - a1, a2 - a1), c2 = Cross(b1 - a1, b2 - a1);
  double c3 = Cross(b2 - a2, a1 - a2), c4 = Cross(b2 - a2, b1 - a2);
  return dcmp(c1) * dcmp(c2) < 0 && dcmp(c3) * dcmp(c4) < 0;
}
bool IsPointOnSegment(Point p, Point a1, Point a2) {
  return dcmp(Cross(p - a1, p - a2)) == 0 && dcmp(Dot(p - a1, p - a2)) < 0;
}
int ConvexHull(Point *p, int n, Point *ch) {
  sort(p + 1, p + n + 1);
  int m = 0;
  for (int i = 1; i <= n; i++) {
    while (m > 1 && Cross(ch[m] - ch[m - 1], p[i] - ch[m - 1]) <= 0) m--;
    ch[++m] = p[i];
  }
  int k = m;
  for (int i = n - 1; i; i--) {
    while (m > k && Cross(ch[m] - ch[m - 1], p[i] - ch[m - 1]) <= 0) m--;
    ch[++m] = p[i];
  }
  if (n > 1) m--;
  return m;
}
double x, y, x2, y2, x3, y3;
Point e[4];
int main() {
  map<Point, int> q;
  for (int i = 0; i <= 3; i++) {
    scanf("%lf%lf%lf%lf", &x, &y, &x2, &y2);
    e[i] = Point(x2 - x, y2 - y);
    q[Point(x, y)]++;
    q[Point(x2, y2)]++;
  }
  int flag = 1;
  if (q.size() != 4) flag = 0;
  map<Point, int>::iterator it;
  for (it = q.begin(); it != q.end(); ++it)
    if (it->second != 2) flag = 0;
  int a = 0, b = 0;
  for (int i = 0; flag && i < 4; ++i) {
    int cnt = 0;
    if (dcmp(Cross(e[i], Point(1, 0))) == 0) cnt++, a++;
    if (dcmp(Cross(e[i], Point(0, 1))) == 0) cnt++, b++;
    if (cnt != 1) flag = 0;
  }
  if (!(a == 2 && b == 2)) flag = 0;
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}

### Prompt

In CPP, your task is to solve 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;
inline int lowbit(int x) { return x & (-x); }
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
template <typename A, typename B, typename C>
inline A fpow(A x, B p, C lyd) {
  A ans = 1;
  for (; p; p >>= 1, x = 1LL * x * x % lyd)
    if (p & 1) ans = 1LL * x * ans % lyd;
  return ans;
}
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
template <typename T>
inline T max(T x, T y, T z) {
  return max(max(x, y), z);
}
template <typename T>
inline T min(T x, T y, T z) {
  return min(min(x, y), z);
}
const double PI = acos(-1);
const double eps = 1e-7;
const int maxn = 1e6 + 10;
const long long INF = 0x3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
double dcmp(double x) {
  if (fabs(x) < eps)
    return 0;
  else
    return x < 0 ? -1 : 1;
}
struct Point {
  double x, y;
  Point(double x0 = 0, double y0 = 0) : x(x0), y(y0) {}
  friend bool operator<(Point a, Point b) {
    return a.x != b.x ? a.x < b.x : a.y < b.y;
  }
  friend Point operator+(const Point &a, const Point &b) {
    return Point(a.x + b.x, a.y + b.y);
  }
  friend Point operator-(const Point &a, const Point &b) {
    return Point(a.x - b.x, a.y - b.y);
  }
  friend Point operator*(const Point &a, double b) {
    return Point(a.x * b, a.y * b);
  }
  friend Point operator/(const Point &a, double b) {
    return Point(a.x / b, a.y / b);
  }
  bool operator==(const Point &a) const {
    return dcmp(x - a.x) == 0 && dcmp(y - a.y) == 0;
  }
};
double Dot(const Point &a, const Point &b) { return a.x * b.x + a.y * b.y; }
double Cross(const Point &a, const Point &b) { return a.x * b.y - a.y * b.x; }
Point getLineIntersection(const Point &P, const Point &v, const Point &Q,
                          const Point &w) {
  Point u = P - Q;
  double t = Cross(w, u) / Cross(v, w);
  return P + v * t;
}
bool SegmentProperIntersection(const Point &a1, const Point &b1,
                               const Point &a2, const Point &b2) {
  double c1 = Cross(b1 - a1, a2 - a1), c2 = Cross(b1 - a1, b2 - a1);
  double c3 = Cross(b2 - a2, a1 - a2), c4 = Cross(b2 - a2, b1 - a2);
  return dcmp(c1) * dcmp(c2) < 0 && dcmp(c3) * dcmp(c4) < 0;
}
bool IsPointOnSegment(Point p, Point a1, Point a2) {
  return dcmp(Cross(p - a1, p - a2)) == 0 && dcmp(Dot(p - a1, p - a2)) < 0;
}
int ConvexHull(Point *p, int n, Point *ch) {
  sort(p + 1, p + n + 1);
  int m = 0;
  for (int i = 1; i <= n; i++) {
    while (m > 1 && Cross(ch[m] - ch[m - 1], p[i] - ch[m - 1]) <= 0) m--;
    ch[++m] = p[i];
  }
  int k = m;
  for (int i = n - 1; i; i--) {
    while (m > k && Cross(ch[m] - ch[m - 1], p[i] - ch[m - 1]) <= 0) m--;
    ch[++m] = p[i];
  }
  if (n > 1) m--;
  return m;
}
double x, y, x2, y2, x3, y3;
Point e[4];
int main() {
  map<Point, int> q;
  for (int i = 0; i <= 3; i++) {
    scanf("%lf%lf%lf%lf", &x, &y, &x2, &y2);
    e[i] = Point(x2 - x, y2 - y);
    q[Point(x, y)]++;
    q[Point(x2, y2)]++;
  }
  int flag = 1;
  if (q.size() != 4) flag = 0;
  map<Point, int>::iterator it;
  for (it = q.begin(); it != q.end(); ++it)
    if (it->second != 2) flag = 0;
  int a = 0, b = 0;
  for (int i = 0; flag && i < 4; ++i) {
    int cnt = 0;
    if (dcmp(Cross(e[i], Point(1, 0))) == 0) cnt++, a++;
    if (dcmp(Cross(e[i], Point(0, 1))) == 0) cnt++, b++;
    if (cnt != 1) flag = 0;
  }
  if (!(a == 2 && b == 2)) flag = 0;
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}

```