#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const long long mod = 1e9 + 7;
long long mul(long long a, long long b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long sum(long long a, long long b) {
  return ((a % mod) + (b % mod)) % mod;
}
long long sub(long long a, long long b) {
  return ((a % mod) - (b % mod)) % mod;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    b >>= 1;
    a = mul(a, a);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int x[4][2], y[4][2];
  for (int i = 0; i < 4; i++) {
    cin >> x[i][0] >> y[i][0] >> x[i][1] >> y[i][1];
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        for (int l = 0; l < 4; l++) {
          set<int> diff = {i, j, k, l};
          if (diff.size() != 4) continue;
          for (int m = 0; m < 2; m++) {
            for (int n = 0; n < 2; n++) {
              for (int o = 0; o < 2; o++) {
                for (int p = 0; p < 2; p++) {
                  if (y[i][m] == y[i][1 - m] && y[j][n] == y[j][1 - n] &&
                      x[k][o] == x[k][1 - o] && x[l][p] == x[l][1 - p] &&
                      x[i][m] == x[k][o] && y[i][m] == y[k][o] &&
                      x[i][1 - m] == x[l][p] && y[i][1 - o] == y[l][p] &&
                      x[j][n] == x[k][1 - o] && y[j][n] == y[k][1 - o] &&
                      x[j][1 - n] == x[l][1 - p] &&
                      y[j][1 - n] == y[l][1 - p]) {
                    long long area =
                        (x[i][1 - m] - x[i][m]) * (y[k][1 - o] - y[k][o]);
                    if (area > 0) {
                      cout << "YES\n";
                      return 0;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << "NO\n";
  return 0;
}

### Prompt

Your challenge is to write 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;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const long long mod = 1e9 + 7;
long long mul(long long a, long long b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long sum(long long a, long long b) {
  return ((a % mod) + (b % mod)) % mod;
}
long long sub(long long a, long long b) {
  return ((a % mod) - (b % mod)) % mod;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    b >>= 1;
    a = mul(a, a);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int x[4][2], y[4][2];
  for (int i = 0; i < 4; i++) {
    cin >> x[i][0] >> y[i][0] >> x[i][1] >> y[i][1];
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        for (int l = 0; l < 4; l++) {
          set<int> diff = {i, j, k, l};
          if (diff.size() != 4) continue;
          for (int m = 0; m < 2; m++) {
            for (int n = 0; n < 2; n++) {
              for (int o = 0; o < 2; o++) {
                for (int p = 0; p < 2; p++) {
                  if (y[i][m] == y[i][1 - m] && y[j][n] == y[j][1 - n] &&
                      x[k][o] == x[k][1 - o] && x[l][p] == x[l][1 - p] &&
                      x[i][m] == x[k][o] && y[i][m] == y[k][o] &&
                      x[i][1 - m] == x[l][p] && y[i][1 - o] == y[l][p] &&
                      x[j][n] == x[k][1 - o] && y[j][n] == y[k][1 - o] &&
                      x[j][1 - n] == x[l][1 - p] &&
                      y[j][1 - n] == y[l][1 - p]) {
                    long long area =
                        (x[i][1 - m] - x[i][m]) * (y[k][1 - o] - y[k][o]);
                    if (area > 0) {
                      cout << "YES\n";
                      return 0;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << "NO\n";
  return 0;
}

```