Bob is playing his favourite game, Balorant.
He is not having a good time because he keeps losing. Of course, Bob thinks that he is the better player so the problem must be his connection speed to the server, otherwise known as ping.
In Globgalob City, where Bob lives, ping works a bit differently. For data to be received, a signal is sent out from the router at location to the server at location , where and are both integers. The data travels in steps in either the positive or negative direction. The distance the data travels at step follows the sequence . The value of is the frequency, which is dependant on the router. The value of is an arbitrary exponent that is determined by the router such that the data will make it to the server while minimizing its value. The ping is the number of steps the data must take before it reaches the server. For this problem, it is guaranteed that the data can be received by the server.
Bob has hacked into his opponent's router and has figured out its location and frequency. He wants you to determine what his and his opponent's pings are. Can you help him?
Input Specification
The first line contains a single integer, the location of the server
The second line contains two integers, the location of Bob's router followed by his router's frequency,
The third line contains two integers, the location of the opponent's router followed by their router's frequency,
Output Specification
Output two space-separated integers, Bob's ping and his opponent's ping.
Sample Input
15
195 6
11 2
Sample Output
2 1
Sample Explanation
Bob's data goes from 195 to 15 as follows . Note, that since the data arrived to the server in two pings, it stops travelling.
His opponent's data goes from 12 to 15 as follows
Comments