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
The Mundane Programmer: 2013-02-17 02:29:39

easy one..........

Ouditchya Sinha: 2013-02-13 08:17:30

@TYAGI thank you for the suggestion... Got AC :)

RAMAKRISHNAN.K: 2013-01-15 08:51:54

Thanks to Tyagi !! take the two people as hands of a clock and think..

Shubham Gupta: 2013-01-14 08:54:29

@saket diwakar thanks, got AC :)

TYAGI: 2012-12-23 18:17:00

simple physics of clock cycle

TYAGI: 2012-12-23 18:16:27

easy 1

tarun sharma: 2012-12-06 06:22:48

getting wa...
give some more test cases...

strings: 2012-12-01 19:07:54

got AC. A big thanx to saket, Shizuo Heiwajima and iwillambush !!
:)

Last edit: 2013-01-12 11:58:02
PRIYAM PANDEY: 2012-10-14 18:02:22

getting wa.. :(.. pls give me some more test cases..

Monkey D. Luffy : 2012-08-26 13:15:13

yeah i did same and and got ac in 1st attempt...


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