GCD2  GCD2
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm
int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); }and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow. Each line consists of two number A and B (0 <= A <= 40000 and A <= B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input: 2 2 6 10 11 Output: 2 1
Source limit is 1,000 Bytes.
hide comments
abdelkarim:
20130105 13:24:23
easy one :D .


Paul Draper:
20121201 21:14:01
Why no Java? 

Mathan Kumar:
20121001 19:26:45
What is the o/p for 0 and 0??


StupidGuy:
20120820 15:16:03
Why no Python 2.7? 

napster:
20120523 13:38:32
nice one!!! 

bond 007:
20120323 07:15:50
runtime error (NZEC)


oldmonk:
20110612 10:47:21
give me some test case it 's giving WA 

Piotr KÄ…kol:
20110503 14:11:51
Also don't understand why such strange language restriction.


:D:
20110104 13:22:52
Floating point error, most often division by 0. You should read the tutorial. 

Fernandes Sinaga:
20110104 11:05:13
what mean of RE SIGFPE?? 
Added by:  Frank Rafael Arteaga 
Date:  20080804 
Time limit:  1s 
Source limit:  1000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: C99 LISP sbcl LISP clisp ERL JAVA JSRHINO NODEJS PERL6 PERL PHP PYTHON RUBY VB.NET 
Resource:  My own Resource 