#include <bits/stdc++.h>
using namespace std;
const long long inf = 2147383647;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
int ext_gcd(int a, int b, int& x, int& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  int x1, y1;
  int d = ext_gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
inline long long modInv(int a, int m) {
  int x, y;
  ext_gcd(a, m, x, y);
  if (x < 0) x += m;
  return x;
}
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
struct segment {
  int x1, y1, x2, y2;
} sg;
vector<segment> ver, hor;
bool process() {
  int y1 = hor[0].y1;
  int y2 = hor[1].y1;
  if (y1 == y2) return false;
  int x1 = hor[0].x1;
  int x2 = hor[0].x2;
  if (x1 == x2) return false;
  if (x1 > x2) swap(x1, x2);
  int tx1 = hor[1].x1;
  int tx2 = hor[1].x2;
  if (tx1 > tx2) swap(tx1, tx2);
  if (x1 != tx1 || x2 != tx2) return false;
  if (y1 > y2) swap(y1, y2);
  int vx1 = ver[0].x1;
  int vx2 = ver[1].x1;
  if (vx1 > vx2) swap(vx1, vx2);
  if (x1 != vx1 || x2 != vx2) return false;
  int ty1 = ver[0].y1;
  int ty2 = ver[0].y2;
  if (ty1 > ty2) swap(ty1, ty2);
  if (y1 != ty1 || y2 != ty2) return false;
  ty1 = ver[1].y1;
  ty2 = ver[1].y2;
  if (ty1 > ty2) swap(ty1, ty2);
  if (y1 != ty1 || y2 != ty2) return false;
  return true;
}
int main() {
  bool pos = true;
  for (int i = (0); i <= (3); ++i) {
    scanf("%d %d %d %d", &sg.x1, &sg.y1, &sg.x2, &sg.y2);
    if (sg.x1 == sg.x2) {
      ver.push_back(sg);
    } else if (sg.y1 == sg.y2) {
      hor.push_back(sg);
    } else {
      pos = false;
      break;
    }
  }
  if (ver.size() != 2 || hor.size() != 2) pos = false;
  if (pos == false) {
    printf("NO\n");
    return 0;
  }
  pos = process();
  if (pos == false) {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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 long inf = 2147383647;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
int ext_gcd(int a, int b, int& x, int& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  int x1, y1;
  int d = ext_gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
inline long long modInv(int a, int m) {
  int x, y;
  ext_gcd(a, m, x, y);
  if (x < 0) x += m;
  return x;
}
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
struct segment {
  int x1, y1, x2, y2;
} sg;
vector<segment> ver, hor;
bool process() {
  int y1 = hor[0].y1;
  int y2 = hor[1].y1;
  if (y1 == y2) return false;
  int x1 = hor[0].x1;
  int x2 = hor[0].x2;
  if (x1 == x2) return false;
  if (x1 > x2) swap(x1, x2);
  int tx1 = hor[1].x1;
  int tx2 = hor[1].x2;
  if (tx1 > tx2) swap(tx1, tx2);
  if (x1 != tx1 || x2 != tx2) return false;
  if (y1 > y2) swap(y1, y2);
  int vx1 = ver[0].x1;
  int vx2 = ver[1].x1;
  if (vx1 > vx2) swap(vx1, vx2);
  if (x1 != vx1 || x2 != vx2) return false;
  int ty1 = ver[0].y1;
  int ty2 = ver[0].y2;
  if (ty1 > ty2) swap(ty1, ty2);
  if (y1 != ty1 || y2 != ty2) return false;
  ty1 = ver[1].y1;
  ty2 = ver[1].y2;
  if (ty1 > ty2) swap(ty1, ty2);
  if (y1 != ty1 || y2 != ty2) return false;
  return true;
}
int main() {
  bool pos = true;
  for (int i = (0); i <= (3); ++i) {
    scanf("%d %d %d %d", &sg.x1, &sg.y1, &sg.x2, &sg.y2);
    if (sg.x1 == sg.x2) {
      ver.push_back(sg);
    } else if (sg.y1 == sg.y2) {
      hor.push_back(sg);
    } else {
      pos = false;
      break;
    }
  }
  if (ver.size() != 2 || hor.size() != 2) pos = false;
  if (pos == false) {
    printf("NO\n");
    return 0;
  }
  pos = process();
  if (pos == false) {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  return 0;
}

```