e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Problems

Segment and a rectangle

Segment and a rectangle

Пересекаются ли отрезок (X1, Y1), (X2, Y2) и прямоугольник с концами диагонали (X3, Y3), (X4, Y4) и сторонами параллельными координатным осям? Прямоугольник и отрезок перескаются, если они имеют хотя бы одну общую точку.

Input

The first line contains four integers X1, Y1, X2, Y2 - the coordinates of the endpoints recorded by a space. The second line contains four integers X3, Y3, X4, Y4 - coordinates of the ends of one diagonal recorded by a space. All coordinates are integers and do not exceed in modulus 50.

Output

Bring out one number 1, if a rectangle and cut intersect or 0 if not.

Time limit 1 second
Memory limit 64 MiB
Input example #1
1 3 4 -1
-1 4 3 -2
Output example #1
1