Andy is a man who likes to think outside the box. Unfortunately for him, there is a large rectangle on the infinite 2-D plane that he is currently traveling on, with its bottom-left corner at and its top-right corner at .
However, Andy is also a man who plans ahead. He will start at a point , and travel at a velocity of horizontal units and vertical units per second . Since Andy is a man of action, he will always be moving. This means that .
Andy would like to know the times when he enters and exits the rectangle. The entering time is the first integer time since starting for when Andy is inside the rectangle. If Andy starts inside the rectangle then his entering time will be . The exiting time is the first integer time after the entering time for when Andy is outside the rectangle. If Andy is never inside the rectangle at an integer time, then the entering and exiting times are both . Note that a point on an edge of the rectangle will count as being inside.
Input Specification
The first line contains four integers , , , and .
The second line contains four integers, , , , , Andy's starting point and velocity.
Output Specification
Output two integers, the entering and exiting times.
Subtasks
Subtask 1 [20%]
One of or will be .
Subtask 2 [80%]
No further constraints.
Sample Input 1
-2 -1 3 3
-1 -2 1 2
Sample Output 1
1 3
Sample Explanation 1
Andy starts at the point at time .
After second, Andy will be at the point , which is inside the rectangle. Therefore the entering time is .
After seconds, Andy will be at the point .
After seconds, Andy will be at the point , which is now outside the rectangle. Therefore the exiting time is .
Sample Input 2
-2 -1 3 3
4 1 1 1
Sample Output 2
-1 -1
Sample Explanation 2
Andy will never go inside the rectangle.
Comments