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>

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.TreeSet;

/*
....x.xxxxx.xxxxx.x...x.xxxxx.xxxxx.xxxxx.......xxxxx.xxxxx.xxxxx
....x.....x.....x.x...x.x.....x.........x...x...x...x.x...x.x...x
....x.....x.....x.x...x.x.....x.........x...x...x...x.x...x.x...x
....x.xxxxx.xxxxx.xxxxx.xxxxx.xxxxx.....x.xxxxx.xxxxx.xxxxx.x...x
....x.x.........x.....x.....x.x...x.....x...x...x...x.....x.x...x
....x.x.........x.....x.....x.x...x.....x...x...x...x.....x.x...x
....x.xxxxx.xxxxx.....x.xxxxx.xxxxx.....x.......xxxxx.xxxxx.xxxxx
 */
/**
 *
 * @author Andy Phan
 */
public class a {

    public static void main(String[] args) {
        FS in = new FS(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        VecL[] a = new VecL[4];
        for(int i = 0; i < 4; i++) a[i] = new VecL(in.nextInt(), in.nextInt());
        VecL[] b = new VecL[4];
        for(int i = 0; i < 4; i++) b[i] = new VecL(in.nextInt(), in.nextInt());

        for(int i = 0; i < 4; i++) {
            int[] num = new int[3];
            SegL t1 = new SegL(b[i], b[(i+1)%4]);
            for(int j = 0; j < 4; j++) {
                SegL t2 = new SegL(a[j], a[(j+1)%4]);
                if(t1.intersects(t2)) {
                    System.out.println("YES");
                    return;
                }
                num[(int)t2.side(b[i])+1]++;
            }
            if(Math.max(num[0], num[2]) == 4) {
                System.out.println("YES");
                return;
            }
        }
        VecL[] tmp = a;
        a = b;
        b = tmp;
        for(int i = 0; i < 4; i++) {
            int[] num = new int[3];
            SegL t1 = new SegL(b[i], b[(i+1)%4]);
            for(int j = 0; j < 4; j++) {
                SegL t2 = new SegL(a[j], a[(j+1)%4]);
                if(t1.intersects(t2)) {
                    System.out.println("YES");
                    return;
                }
                num[(int)t2.side(b[i])+1]++;
            }
            if(Math.max(num[0], num[2]) == 4) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
        out.close();
    }

    static class VecL implements Comparable<VecL> {

        long x, y;

        public VecL(long x, long y) {
            this.x = x;
            this.y = y;
        }

        public VecL add(VecL o) {
            return new VecL(x + o.x, y + o.y);
        }

        public VecL sub(VecL o) {
            return new VecL(x - o.x, y - o.y);
        }

        public VecL scale(long s) {
            return new VecL(x * s, y * s);
        }

        public long dot(VecL o) {
            return x * o.x + y * o.y;
        }

        public long cross(VecL o) {
            return x * o.y - y * o.x;
        }

        public long mag2() {
            return dot(this);
        }

        public VecL rot90() {
            return new VecL(-y, x);
        }

        public VecL rot270() {
            return new VecL(y, -x);
        }

        public String toString() {
            return "(" + x + ", " + y + ")";
        }

        public int hashCode() {
            return Long.hashCode(x << 13 ^ (y * 57));
        }

        public boolean equals(Object oo) {
            VecL o = (VecL) oo;
            return x == o.x && y == o.y;
        }

        public int compareTo(VecL o) {
            if (x != o.x) {
                return Long.compare(x, o.x);
            }
            return Long.compare(y, o.y);
        }

        //origin->q1, axes-> quadrant in ccw direction
        public int quadrant() {
            if (x == 0 || y == 0) {
                if (y == 0) {
                    if (x >= 0) {
                        return 1;
                    } else {
                        return 3;
                    }
                } else if (y >= 0) {
                    return 2;
                } else {
                    return 4;
                }
            }
            if (x > 0) {
                if (y > 0) {
                    return 1;
                } else {
                    return 4;
                }
            } else if (y > 0) {
                return 2;
            } else {
                return 3;
            }
        }

        public int radialCompare(VecL o) {
            if (quadrant() == o.quadrant()) {
                return -Long.signum(cross(o));
            }
            return Integer.compare(quadrant(), o.quadrant());
        }
    }

    static class SegL {

        VecL from, to, dir;

        public SegL(VecL from, VecL to) {
            this.from = from;
            this.to = to;
            dir = to.sub(from);
        }

        //check if the segment contains the point
        public boolean contains(VecL p) {
            VecL d = p.sub(from);
            if (d.cross(dir) != 0) {
                return false;
            }
            long dot = d.dot(dir);
            return dot >= 0 && dot <= dir.mag2();
        }

        //(assuming I go left to right)
        //returns:
        //	1 if point is above me
        //	0 if point is on me
        //	-1 if point is below me
        public long side(VecL o) {
            long cross = dir.cross(o.sub(from));
            return cross == 0 ? 0 : cross / Math.abs(cross);
        }

        //returns true if this segl intersects the other, including at endpoints
        //note: returns false if the two segments lie on the same line
        public boolean intersects(SegL o) {
            return side(o.from) != side(o.to) && o.side(from) != o.side(to);
        }

        public String toString() {
            return from + " -> " + to;
        }

        //#
        static long gcd(long a, long b) {
            a = Math.abs(a);
            b = Math.abs(b);
            return b == 0 ? a : gcd(b, a % b);
        }
        //$

        //returns the lattice point of intersection or null if it is nonlattice or does not exist 
        public VecL latticeIntersect(SegL o) {
            if (!intersects(o)) {
                return null;
            }
            long dirGCD = gcd(dir.x, dir.y), oDirGCD = gcd(o.dir.x, o.dir.y);
            VecL va=new   VecL(dir.x / dirGCD, dir.y / dirGCD), vb = new VecL(o.dir.x / oDirGCD, o.dir.y / oDirGCD);
            if (va.x < 0 && va.y < 0) {
                va.x *= -1;
                va.y *= -1;
            }
            if (vb.x < 0 && vb.y < 0) {
                vb.x *= -1;
                vb.y *= -1;
            }
            if (va.equals(vb)) {
                return null;
            }
            long bottomScalar = va.x / gcd(va.x, va.y);
            long topScalar = va.y / gcd(va.x, va.y);
            long t2Scalar = -bottomScalar * vb.y + topScalar * vb.x;
            long t2Ans = bottomScalar * (o.from.y - from.y) - topScalar * (o.from.x - from.x);
            if (t2Ans % t2Scalar != 0) {
                return null;
            }
            long t2 = t2Ans / t2Scalar;
            return new VecL(t2 * vb.x + o.from.x, t2 * vb.y + o.from.y);
        }
    }

    static class FS {

        BufferedReader in;
        StringTokenizer token;

        public FS(InputStream str) {
            in = new BufferedReader(new InputStreamReader(str));
        }

        public String next() {
            if (token == null || !token.hasMoreElements()) {
                try {
                    token = new StringTokenizer(in.readLine());
                } catch (IOException ex) {
                }
                return next();
            }
            return token.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}
