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 32bit 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
AMIT KUMAR YADAV:
20150617 15:22:22
SPEED THRILLS ;P 

_R0b_:
20150427 10:12:25
hint  gcd 

Ashish Sareen:
20141029 12:49:30
Cool One!! 

humblefool_2:
20140525 21:37:23
I dont understand the test cases..what does "meet at distinct points mean"? 

Omar ِAlsherbini:
20140131 00:21:15
I think the question should have told us more about the type of the variables, S1 and S2. 

harshil sukhadia:
20131030 02:57:25
i think something is missing because if they run indefinitely and have distinct speeds than they will meet infinite times...??


nsaini:
20130819 20:42:23
getting WA


:
20130618 13:36:37
all abt relative motion n maths thanx to @saket diwaker and @tyagi


ওয়াসী (Wasi):
20130509 07:06:06
solved it with 0.10 run time on python 3.2.3

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