Problem:
Problem A: Greatest Common Divisor

Please find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task.

Input

The input file consists of several lines with pairs of two natural numbers in each line. The numbers do not exceed 100000.

The number of pairs (datasets) is less than 50.

Output

Your program has to print the greatest common divisor for each pair of input numbers. Print each result on a new line.

Sample Input

57 38
60 84

Output for the Sample Input

19
12

Solution in JAVA (judge verdict: Accepted)

import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    static int gcm( final int n, final int m ) {

	if ( n < m ) {
	    return gcm( m, n );
	} else if( m == 0 ) {
	    return n;	    
	} else {
	    return gcm( m, n % m );
	}
    }
    
    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( stdin.hasNextInt() ) {

	    final int n = stdin.nextInt();
	    final int m = stdin.nextInt();

	    System.out.println( gcm( n, m ) );
	    
	}	
    }    
}