#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-9;
const int MAX_N = 1e6 + 5;
const int inf = 2e9;
const long long Inf = (long long)1e18;
const long long M = (long long)1e9 + 7;
int Int() {
  int x;
  scanf("%d", &x);
  return x;
}
long long Long() {
  long long x;
  scanf("%lld", &x);
  return x;
}
void Char(char* ch) { scanf("%s", ch); }
template <typename t>
inline t abs(t a) {
  if (a >= 0) return a;
  return -a;
}
template <typename t>
inline t gcd(t a, t b) {
  return !b ? a : gcd(b, a % b);
}
template <typename t>
inline t lcm(t a, t b) {
  return a * (b / gcd(a, b));
}
template <typename T>
inline T modpow(T b, T p, T Mod) {
  T res = 1;
  while (p > 0) {
    if (p & 1) {
      res *= b;
      res %= Mod;
    }
    b *= b;
    b %= Mod;
    p >>= 1;
  }
  return res;
}
template <typename T>
inline T ModInv(T b, T Mod) {
  return modpow(b, Mod - 2, Mod);
}
template <typename T>
inline T pwr(T b, T p) {
  T res = 1;
  while (p > 0) {
    if (p & 1) {
      res *= b;
    }
    b *= b;
    p >>= 1;
  }
  return res;
}
int e1, e2, d1;
template <typename T>
inline void extgcd(T a, T b) {
  if (!b) {
    e1 = 1, e2 = 0, d1 = a;
    return;
  }
  extgcd(b, a % b);
  T x1 = e2;
  T y1 = e1 - (a / b) * e2;
  e1 = x1;
  e2 = y1;
}
template <typename T>
inline vector<T> Unique(vector<T> v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " ";
  err(++it, args...);
}
struct point {
  int x, y, x1, y1;
  bool operator==(point p) {
    return x == p.x and y == p.y and x1 == p.x1 and y1 == p.y1;
  }
} p[5];
int check(point a) {
  if (a.x == a.x1 and a.y == a.y1) return 0;
  if (a.x == a.x1)
    return 1;
  else if (a.y == a.y1)
    return 2;
  else
    return 0;
}
int cal(point a) {
  return ((a.x - a.x1) * (a.x - a.x1)) + ((a.y - a.y1) * (a.y - a.y1));
}
int main() {
  int t = 1, tc = 0;
  while (t--) {
    std::vector<int> v[3];
    for (int i = 1; i <= 4; i++) {
      int x1 = Int(), y1 = Int(), x2 = Int(), y2 = Int();
      if (x1 > x2) {
        swap(x1, x2);
      } else if (y1 > y2) {
        swap(y1, y2);
      }
      p[i] = {x1, y1, x2, y2};
      int f = check(p[i]);
      if (f == 0) return puts("NO"), 0;
      v[f].push_back(i);
    }
    if (v[1].size() != v[2].size()) return puts("NO"), 0;
    int len1 = cal(p[v[1][0]]);
    int len2 = cal(p[v[1][1]]);
    if (len1 != len2 or p[v[1][0]] == p[v[1][1]]) return puts("NO"), 0;
    int len = len1;
    len1 = cal(p[v[2][0]]);
    len2 = cal(p[v[2][1]]);
    if (len1 != len2 or p[v[2][0]] == p[v[2][1]]) return puts("NO"), 0;
    int ver = cal({p[v[1][0]].x, p[v[1][0]].y, p[v[1][1]].x, p[v[1][1]].y});
    int hor = cal({p[v[2][0]].x, p[v[2][0]].y, p[v[2][1]].x, p[v[2][1]].y});
    if (ver != len1 or hor != len) return puts("NO"), 0;
    puts("YES");
  }
  return 0;
}

### 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 int N = 2e5 + 5;
const double eps = 1e-9;
const int MAX_N = 1e6 + 5;
const int inf = 2e9;
const long long Inf = (long long)1e18;
const long long M = (long long)1e9 + 7;
int Int() {
  int x;
  scanf("%d", &x);
  return x;
}
long long Long() {
  long long x;
  scanf("%lld", &x);
  return x;
}
void Char(char* ch) { scanf("%s", ch); }
template <typename t>
inline t abs(t a) {
  if (a >= 0) return a;
  return -a;
}
template <typename t>
inline t gcd(t a, t b) {
  return !b ? a : gcd(b, a % b);
}
template <typename t>
inline t lcm(t a, t b) {
  return a * (b / gcd(a, b));
}
template <typename T>
inline T modpow(T b, T p, T Mod) {
  T res = 1;
  while (p > 0) {
    if (p & 1) {
      res *= b;
      res %= Mod;
    }
    b *= b;
    b %= Mod;
    p >>= 1;
  }
  return res;
}
template <typename T>
inline T ModInv(T b, T Mod) {
  return modpow(b, Mod - 2, Mod);
}
template <typename T>
inline T pwr(T b, T p) {
  T res = 1;
  while (p > 0) {
    if (p & 1) {
      res *= b;
    }
    b *= b;
    p >>= 1;
  }
  return res;
}
int e1, e2, d1;
template <typename T>
inline void extgcd(T a, T b) {
  if (!b) {
    e1 = 1, e2 = 0, d1 = a;
    return;
  }
  extgcd(b, a % b);
  T x1 = e2;
  T y1 = e1 - (a / b) * e2;
  e1 = x1;
  e2 = y1;
}
template <typename T>
inline vector<T> Unique(vector<T> v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " ";
  err(++it, args...);
}
struct point {
  int x, y, x1, y1;
  bool operator==(point p) {
    return x == p.x and y == p.y and x1 == p.x1 and y1 == p.y1;
  }
} p[5];
int check(point a) {
  if (a.x == a.x1 and a.y == a.y1) return 0;
  if (a.x == a.x1)
    return 1;
  else if (a.y == a.y1)
    return 2;
  else
    return 0;
}
int cal(point a) {
  return ((a.x - a.x1) * (a.x - a.x1)) + ((a.y - a.y1) * (a.y - a.y1));
}
int main() {
  int t = 1, tc = 0;
  while (t--) {
    std::vector<int> v[3];
    for (int i = 1; i <= 4; i++) {
      int x1 = Int(), y1 = Int(), x2 = Int(), y2 = Int();
      if (x1 > x2) {
        swap(x1, x2);
      } else if (y1 > y2) {
        swap(y1, y2);
      }
      p[i] = {x1, y1, x2, y2};
      int f = check(p[i]);
      if (f == 0) return puts("NO"), 0;
      v[f].push_back(i);
    }
    if (v[1].size() != v[2].size()) return puts("NO"), 0;
    int len1 = cal(p[v[1][0]]);
    int len2 = cal(p[v[1][1]]);
    if (len1 != len2 or p[v[1][0]] == p[v[1][1]]) return puts("NO"), 0;
    int len = len1;
    len1 = cal(p[v[2][0]]);
    len2 = cal(p[v[2][1]]);
    if (len1 != len2 or p[v[2][0]] == p[v[2][1]]) return puts("NO"), 0;
    int ver = cal({p[v[1][0]].x, p[v[1][0]].y, p[v[1][1]].x, p[v[1][1]].y});
    int hor = cal({p[v[2][0]].x, p[v[2][0]].y, p[v[2][1]].x, p[v[2][1]].y});
    if (ver != len1 or hor != len) return puts("NO"), 0;
    puts("YES");
  }
  return 0;
}

```