#include <bits/stdc++.h>
using namespace std;
bool isprime(long long a) {
  for (long long i = 2; i <= sqrt(a); i++) {
    if (a % i == 0) return false;
  }
  return true;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / (gcd(a, b)); }
long long fact(long long n) {
  long long s = 1;
  for (long long i = 1, s = 1; i <= n; i++) {
    s *= i;
    if (i == n) return s;
  }
  return 1;
}
string itos(long long num) {
  ostringstream str1;
  str1 << num;
  string geek = str1.str();
  return geek;
}
long long comb(long long a, long long b) {
  long long mi = min(b, a - b);
  long long ma = max(b, a - b);
  long long s = 1;
  for (long long i = a; i > ma; i--) {
    s *= i;
    cout << i << " ";
  }
  cout << endl;
  return s / fact(mi);
}
long long mi = INT_MAX;
long long ma = 0;
void dfs(long long a, long long vis[], vector<long long> adj[]) {
  mi = min(mi, a);
  ma = max(ma, a);
  vis[a] = 1;
  for (long long x : adj[a]) {
    if (!vis[x]) {
      dfs(x, vis, adj);
    }
  }
}
bool safe(long long x, long long y, long long n, long long m) {
  return (x >= 0 && x < n && y >= 0 && y < m);
}
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  map<pair<long long, long long>, vector<pair<long long, long long>>> m;
  map<long long, long long> f;
  map<pair<pair<long long, long long>, pair<long long, long long>>, long long>
      ma;
  long long i, j;
  long long x, y, x0, y0;
  for (i = 0; i < 4; i++) {
    cin >> x >> y >> x0 >> y0;
    if (ma[{{x, y}, {x0, y0}}] == 0 && ma[{{x0, y0}, {x, y}}] == 0) {
      ma[{{x, y}, {x0, y0}}]++;
      m[{x, y}].push_back({x0, y0});
      m[{x0, y0}].push_back({x, y});
    } else {
      cout << "NO" << endl;
      return 0;
    }
    if (x == x0 && y == y0) {
      cout << "NO" << endl;
      return 0;
    }
    if (x != x0 && y != y0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (m.size() > 4) {
    cout << "NO" << endl;
  } else {
    for (auto it : m) {
      for (auto iter : it.second) {
        long long q = it.first.first - iter.first;
        long long w = it.first.second - iter.second;
        q = q * q;
        w = w * w;
        f[q + w]++;
      }
    }
    if ((f.size() == 2 && (*f.begin()).second == 4 &&
         (*f.rbegin()).second == 4))
      cout << "YES" << endl;
    else if (f.size() == 1 && (*f.begin()).second == 8)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

### Prompt

Develop a solution in Cpp 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;
bool isprime(long long a) {
  for (long long i = 2; i <= sqrt(a); i++) {
    if (a % i == 0) return false;
  }
  return true;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / (gcd(a, b)); }
long long fact(long long n) {
  long long s = 1;
  for (long long i = 1, s = 1; i <= n; i++) {
    s *= i;
    if (i == n) return s;
  }
  return 1;
}
string itos(long long num) {
  ostringstream str1;
  str1 << num;
  string geek = str1.str();
  return geek;
}
long long comb(long long a, long long b) {
  long long mi = min(b, a - b);
  long long ma = max(b, a - b);
  long long s = 1;
  for (long long i = a; i > ma; i--) {
    s *= i;
    cout << i << " ";
  }
  cout << endl;
  return s / fact(mi);
}
long long mi = INT_MAX;
long long ma = 0;
void dfs(long long a, long long vis[], vector<long long> adj[]) {
  mi = min(mi, a);
  ma = max(ma, a);
  vis[a] = 1;
  for (long long x : adj[a]) {
    if (!vis[x]) {
      dfs(x, vis, adj);
    }
  }
}
bool safe(long long x, long long y, long long n, long long m) {
  return (x >= 0 && x < n && y >= 0 && y < m);
}
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  map<pair<long long, long long>, vector<pair<long long, long long>>> m;
  map<long long, long long> f;
  map<pair<pair<long long, long long>, pair<long long, long long>>, long long>
      ma;
  long long i, j;
  long long x, y, x0, y0;
  for (i = 0; i < 4; i++) {
    cin >> x >> y >> x0 >> y0;
    if (ma[{{x, y}, {x0, y0}}] == 0 && ma[{{x0, y0}, {x, y}}] == 0) {
      ma[{{x, y}, {x0, y0}}]++;
      m[{x, y}].push_back({x0, y0});
      m[{x0, y0}].push_back({x, y});
    } else {
      cout << "NO" << endl;
      return 0;
    }
    if (x == x0 && y == y0) {
      cout << "NO" << endl;
      return 0;
    }
    if (x != x0 && y != y0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (m.size() > 4) {
    cout << "NO" << endl;
  } else {
    for (auto it : m) {
      for (auto iter : it.second) {
        long long q = it.first.first - iter.first;
        long long w = it.first.second - iter.second;
        q = q * q;
        w = w * w;
        f[q + w]++;
      }
    }
    if ((f.size() == 2 && (*f.begin()).second == 4 &&
         (*f.rbegin()).second == 4))
      cout << "YES" << endl;
    else if (f.size() == 1 && (*f.begin()).second == 8)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

```