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: Wrong Answer)

import java.io.*;

/**
 * ??´??°?????\??? "x" ????????????x???3????????????????????????
 * (1 ??? x ??? 100)
 * 
 * (ex)
 * 1 -> 1
 * 3 -> 27
 * 100 -> 1000000
 * 
 * @author dawkins_j
 */
class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line;
            while((line = br.readLine()) != null) {
            	String[] list = line.split(" ", 0);
            int 	x = Integer.parseInt(list[0]);
            	int y = Integer.parseInt(list[1]);
            	while(y > 0){
                    int r = x%y;
                    x = y;
                    y = r;
                    System.out.println(getCubicOf(x, y));
                }
            	if(x > y) {
            		int r = x;
            		x = y;
            		y = r;
            		System.out.println(getCubicOf(y, x));
            }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * @param line
     *            ??´??°x?????\???
     * @return x???3???
     */
    private static long getCubicOf(int x, int y) {
    	if(y == 0) {
            return x;
        }else{
            return getCubicOf(y, x % y);
        }
    }
}