COMDIV - Number of common divisors

You will be given T (T<=10^6) pair of numbers. All you have to tell is the number of common divisors between two numbers in each pair.

Input

First line of input: T (Number of test cases)
In next T lines, each have one pair A B (0 < A, B <= 10^6)

Output

One integer describing number of common divisors between two numbers.

Example

Input:
3
100000 100000
12 24
747794 238336 Output: 36
6
2

Added by:Mir Wasi Ahmed
Date:2010-10-31
Time limit:0.600s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own problem, used in UODA TST

hide comments
2013-02-04 13:45:58 Meraj Ahmed
Mir Wasi Ahmed, please check and tell what is wrong with my solution.
id: 8652675

got it!

Last edit: 2013-12-26 18:46:14
2013-02-02 22:49:42 Spar!k
AC with scanf/printf
2013-01-28 12:44:03 ANKUR GARG
can u give some more tricky test cases as these are working fine in my code but m still getting WA
2013-01-20 11:41:52 Darky
@Arunesh Pandey: 1
2013-01-20 09:29:50 Arunesh Pandey
what will be the output for 3 13 ?
2013-01-19 13:30:11 dipak yadav
my id is 8535685
why WA


Last edit: 2013-01-19 13:32:19
2013-01-19 13:24:44 dipak yadav
what is wrong in my code id is 8535685
why Wa

2013-01-01 20:55:09 DEVANSH PARASHAR
tle
2012-12-31 20:40:41 Retaliation
check my solution. Why am i getting tle ? submission id :-8386786
2012-06-21 03:37:36 spock
finally..green light.. :P
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.