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
2011-09-01 13:16:46 Shizuo Heiwajima
What should be output for :
5
8 3
7 2
8 5
3 -2
-1 4
??
2011-08-22 11:39:45 Gaurav Mittal
enough, why am i getting wrong answer
my sub. id is : 5548979.
could you please check it?

Last edit: 2011-08-22 12:14:32
2011-08-18 08:46:52 Dravid
so simple....:D
2011-08-07 08:46:08 arshak minasyan
@Alejandro Flores
the S1 and S2 are distnict)
2011-07-31 04:01:18 Alejandro Flores
Hi !
What should be the output for:
1
1 1
?? 0 ?
2011-07-28 07:29:13 Vimal Raj Sharma
awesome problem :)
2011-07-26 14:22:10 nagesh
Nice one..:D
2011-07-25 18:56:08 blashyrkh
@Hagen von Eitzen: no :)
2011-07-25 18:01:23 Hagen von Eitzen
The sample cases seem to imply that the diameter of the track is approximately 0.31830988618379
2011-07-24 21:48:10 .:: Pratik ::.
What is the length of the track?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.