SPEED - Circular Track

Two persons are running on a circular track either in the same direction or in the opposite direction, indefinitely. The speed of both of them is given to you. Speed will be positive in clockwise direction, and negative in anticlockwise direction. Print the number of distinct points, at which they will meet on the circle.

Input

First line contains T, number of test cases. Each test case contains two integers, S1 and S2 (not equal to zero) which are the speeds of the two persons. S1 and S2 will be distinct.

Edited: All the numbers fit in signed 32-bit integer.

Output

Print in a separate line, the number of distinct points at which they meet.

Example

Input
2
1 2
1 -1

Output
1
2

Added by:Nikunj Jain
Date:2011-07-21
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

hide comments
2012-07-15 04:59:56 Simón Murillo Gómez
@saket diwakar thanks, got AC :)
2012-06-10 06:07:11 Nikhar Agrawal
What is the upper limit of S1 and S2.
2012-05-29 21:49:19 ajax
can anyone tell me a test case where the chances of errors are very much ?
please i am getting WA ?
2012-01-19 16:02:52 Prashant Gupta
since radius is not given in the problem think otherway.....
2012-01-10 15:45:05 saket diwakar
if u r getting WA..
try your program at these inputs..
6 3 ==>1
3 -3==>2...
2011-12-20 16:34:00 Ajey Golsangi
@Shizuo Heiwajima
5
5
3
5
5
2011-10-14 18:58:20 ash
Should we calculate the number of times the athletes meet till the first one completes one round or till the slower one completes one round??
2011-09-20 14:45:08 Chandan Giri
nice :)
2011-09-05 15:42:20 !(accepted)
looked tricky but turned out to be an easy one..
2011-09-03 13:18:37 Akshat Aggarwal
whats the constraints on maximum value on S1 and S2
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.