You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect.

The interior of the square is considered to be part of the square, i.e. if one square is completely inside another, they intersect. If the two squares only share one common point, they are also considered to intersect.

Input

The input data consists of two lines, one for each square, both containing 4 pairs of integers. Each pair represents coordinates of one vertex of the square. Coordinates within each line are either in clockwise or counterclockwise order.

The first line contains the coordinates of the square with sides parallel to the coordinate axes, the second line contains the coordinates of the square at 45 degrees.

All the values are integer and between -100 and 100.

Output

Print "Yes" if squares intersect, otherwise print "No".

You can print each letter in any case (upper or lower).

Examples

Input

0 0 6 0 6 6 0 6
1 3 3 5 5 3 3 1


Output

YES


Input

0 0 6 0 6 6 0 6
7 3 9 5 11 3 9 1


Output

NO


Input

6 0 6 6 0 6 0 0
7 4 4 7 7 10 10 7


Output

YES

Note

In the first example the second square lies entirely within the first square, so they do intersect.

In the second sample squares do not have any points in common.

Here are images corresponding to the samples:

<image> <image> <image>
#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0), eps = 1e-7;
template <class T>
struct point {
  T x, y;
  point(T x = (T)0, T y = (T)0) : x(x), y(y) {}
  bool operator<(const point &o) const { return x != o.x ? x < o.x : y < o.y; }
  bool operator==(const point &o) const {
    return abs(o.x - x) <= (T)eps and abs(o.y - y) <= (T)eps;
  }
  bool operator<=(const point &o) const { return *this == o or *this < o; }
  point operator+(const point &p) const { return point(x + p.x, y + p.y); }
  point &operator+=(const point &p) {
    x += p.x;
    y += p.y;
    return *this;
  }
  point operator-(const point &p) const { return point(x - p.x, y - p.y); }
  point &operator-=(const point &p) const {
    x -= p.x;
    y -= p.y;
    return *this;
  }
  point operator*(T a) const { return point(x * a, y * a); }
  point &operator*=(T a) {
    x *= a;
    y *= a;
    return *this;
  }
  point operator/(T a) const { return point(x / a, y / a); }
  point &operator/=(T a) {
    x /= a;
    y /= a;
    return *this;
  }
  T operator*(const point &p) const { return x * p.x + y * p.y; }
  T operator^(const point &p) const { return x * p.y - y * p.x; }
  long double angle() const { return atan2(y, x); }
  long double dist(const point &p) const { return hypot(x - p.x, y - p.y); }
  long double norm() const { return hypot(x, y); }
  point &normalize() { return *this /= norm(); }
  T sqnorm() const { return x * x + y * y; }
  point &operator-() {
    x = -x;
    y = -y;
    return *this;
  }
};
point<long long> operator*(long long a, point<long long> &p) { return p * a; }
point<long double> operator*(long double a, point<long double> &p) {
  return p * a;
}
point<int> operator*(int a, point<int> &p) { return p * a; }
point<long double> polar(long double r, long double theta) {
  return point<long double>(r * cos(theta), r * sin(theta));
}
template <class T>
istream &operator>>(istream &in, point<T> &p) {
  return in >> p.x >> p.y;
}
template <class T>
ostream &operator<<(ostream &out, point<T> &p) {
  return out << p.x << ' ' << p.y;
}
template <class T>
int sgn(T x) {
  return x > (T)eps ? 1 : x < -(T)eps ? -1 : 0;
}
template <class T>
bool intersect(point<T> &a, point<T> &b, point<T> &c, point<T> &d) {
  return sgn((c - a) ^ (b - a)) * sgn((d - a) ^ (b - a)) <= 0 &&
         sgn((a - c) ^ (d - c)) * sgn((b - c) ^ (d - c)) <= 0;
}
template <class T>
bool inside(vector<point<T>> &P1, vector<point<T>> &P2) {
  for (int i = 0; i < P1.size(); i++) {
    point<T> A1 = P1[i];
    int ss;
    for (int j = 0; j < P2.size(); j++) {
      point<T> A2 = P2[j];
      point<T> A3 = P2[(j + 1) % 4];
      point<T> a = A1 - A2;
      point<T> b = A3 - A2;
      int s = sgn(a ^ b);
      if (j == 0)
        ss = s;
      else {
        if (s != ss) {
          return false;
        }
      }
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  vector<vector<point<int>>> square(2, vector<point<int>>(4));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> square[i][j];
    }
  }
  for (int i = 0; i < 4; i++) {
    point<int> A1 = square[0][i];
    point<int> A2 = square[0][(i + 1) % 4];
    for (int j = 0; j < 4; j++) {
      point<int> A3 = square[1][j];
      point<int> A4 = square[1][(j + 1) % 4];
      if (intersect(A1, A2, A3, A4)) {
        cout << "YES\n";
        return 0;
      }
    }
  }
  bool inside1 = inside(square[0], square[1]);
  bool inside2 = inside(square[1], square[0]);
  if (inside1 or inside2) {
    cout << "YES\n";
    return 0;
  }
  cout << "NO\n";
  return 0;
}
