SPEED - Circular Track

no tags 

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

hide comments
Simón Murillo Gómez: 2012-07-15 04:59:56

@saket diwakar thanks, got AC :)

Nikhar Agrawal: 2012-06-10 06:07:11

What is the upper limit of S1 and S2.

ajax: 2012-05-29 21:49:19

can anyone tell me a test case where the chances of errors are very much ?
please i am getting WA ?

Prashant Gupta: 2012-01-19 16:02:52

since radius is not given in the problem think otherway.....

saket diwakar: 2012-01-10 15:45:05

if u r getting WA..
try your program at these inputs..
6 3 ==>1
3 -3==>2...

Ajey Golsangi: 2011-12-20 16:34:00

@Shizuo Heiwajima
5
5
3
5
5

ash: 2011-10-14 18:58:20

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??

Chandan Giri: 2011-09-20 14:45:08

nice :)

!(accepted): 2011-09-05 15:42:20

looked tricky but turned out to be an easy one..

Akshat Aggarwal: 2011-09-03 13:18:37

whats the constraints on maximum value on S1 and S2


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