Hide

Problem D
Forest for the Trees

You are playing hide-and-go-seek in a forest with Belle. The forest has one tree at each of the positive integer lattice points. That is, there is a tree at every point (x,y) where x and y are both positive integers. You may consider each tree as a point. A logging company has cut down all of the trees in some axis-aligned rectangle, including those on the boundary of the rectangle.

You are standing at (0,0) and Belle is standing at (xb,yb). You can see Belle if and only if there is no tree blocking your line of sight to Belle. If there is a tree at (xb,yb), Belle will make it easier for you to find her by standing on the side of the tree facing your location.

For example, suppose that Belle is standing at (2,6). If the trees in the rectangle with corners at (1,1) and (5,4) are cut down (blue rectangle in figure), then you can see Belle. However, if the rectangle was at (3,5) and (5,7) (red rectangle in figure), then the tree at (1,3) would be in the way.

\includegraphics[width=0.45\textwidth ]{trees.pdf}

Given the rectangle and Belle’s location, can you see her?

Input

The first line of input contains two integer xb and yb (1xb,yb1012), which are the coordinates that Belle is standing on.

The second line of input contains four integers x1, y1, x2 and y2 (1x1x21012 and 1y1y21012), which specify two opposite corners of the rectangle at (x1,y1) and (x2,y2).

Output

If you can see Belle, display Yes.

Otherwise, display No and the coordinates of the closest tree that is blocking your view.

Sample Input 1 Sample Output 1
2 6
1 1 5 4
Yes
Sample Input 2 Sample Output 2
2 6
3 5 5 7
No
1 3
Sample Input 3 Sample Output 3
830844890448 39710592053
821266 42860 402207107926 423171345006
No
402207964848 19223704203
Hide

Please log in to submit a solution to this problem

Log in