import java.util.Scanner;

/**
 * Created by ??\??? on 2016/12/2.
 */
public class Main {
    static int gcd(int a,int b)
    {
        while(b!=0)
        {
            int ans = a%b;
            a = b;
            if(ans!=0)
            {
                b = ans;
            }
            else
            {
                return a;
            }
        }
        return -1;
    }
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext())
        {
            String[] lines = scan.nextLine().split(" ");
            int a = Integer.parseInt(lines[0]);
            int b = Integer.parseInt(lines[1]);
            System.out.println(gcd(a,b));
        }
        return 0;
    }
    public static void main(String[] args)
    {
        run(args);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    static int gcd(int a,int b)
    {
        while(b!=0)
        {
            int ans = a%b;
            a = b;
            if(ans!=0)
            {
                b = ans;
            }
            else
            {
                return a;
            }
        }
        return -1;
    }
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext())
        {
            String[] lines = scan.nextLine().split(" ");
            int a = Integer.parseInt(lines[0]);
            int b = Integer.parseInt(lines[1]);
            System.out.println(gcd(a,b));
        }
        return 0;
    }
    public static void main(String[] args)
    {
        run(args);
    }
} Main static int gcd(int a,int b)
    {
        while(b!=0)
        {
            int ans = a%b;
            a = b;
            if(ans!=0)
            {
                b = ans;
            }
            else
            {
                return a;
            }
        }
        return -1;
    } gcd {
        while(b!=0)
        {
            int ans = a%b;
            a = b;
            if(ans!=0)
            {
                b = ans;
            }
            else
            {
                return a;
            }
        }
        return -1;
    } while(b!=0)
        {
            int ans = a%b;
            a = b;
            if(ans!=0)
            {
                b = ans;
            }
            else
            {
                return a;
            }
        } b!=0 b 0 {
            int ans = a%b;
            a = b;
            if(ans!=0)
            {
                b = ans;
            }
            else
            {
                return a;
            }
        } int ans = a%b; ans a%b a b a = b a b if(ans!=0)
            {
                b = ans;
            }
            else
            {
                return a;
            } ans!=0 ans 0 {
                b = ans;
            } b = ans b ans {
                return a;
            } return a; a return -1; -1 1 int a a int b b static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext())
        {
            String[] lines = scan.nextLine().split(" ");
            int a = Integer.parseInt(lines[0]);
            int b = Integer.parseInt(lines[1]);
            System.out.println(gcd(a,b));
        }
        return 0;
    } run {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext())
        {
            String[] lines = scan.nextLine().split(" ");
            int a = Integer.parseInt(lines[0]);
            int b = Integer.parseInt(lines[1]);
            System.out.println(gcd(a,b));
        }
        return 0;
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(scan.hasNext())
        {
            String[] lines = scan.nextLine().split(" ");
            int a = Integer.parseInt(lines[0]);
            int b = Integer.parseInt(lines[1]);
            System.out.println(gcd(a,b));
        } scan.hasNext() scan.hasNext scan {
            String[] lines = scan.nextLine().split(" ");
            int a = Integer.parseInt(lines[0]);
            int b = Integer.parseInt(lines[1]);
            System.out.println(gcd(a,b));
        } String[] lines = scan.nextLine().split(" "); lines scan.nextLine().split(" ") scan.nextLine().split scan.nextLine() scan.nextLine scan " " int a = Integer.parseInt(lines[0]); a Integer.parseInt(lines[0]) Integer.parseInt Integer lines[0] lines 0 int b = Integer.parseInt(lines[1]); b Integer.parseInt(lines[1]) Integer.parseInt Integer lines[1] lines 1 System.out.println(gcd(a,b)) System.out.println System.out System System.out gcd(a,b) gcd a b return 0; 0 String[] args args public static void main(String[] args)
    {
        run(args);
    } main {
        run(args);
    } run(args) run args String[] args args public class Main {
    static int gcd(int a,int b)
    {
        while(b!=0)
        {
            int ans = a%b;
            a = b;
            if(ans!=0)
            {
                b = ans;
            }
            else
            {
                return a;
            }
        }
        return -1;
    }
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext())
        {
            String[] lines = scan.nextLine().split(" ");
            int a = Integer.parseInt(lines[0]);
            int b = Integer.parseInt(lines[1]);
            System.out.println(gcd(a,b));
        }
        return 0;
    }
    public static void main(String[] args)
    {
        run(args);
    }
} public class Main {
    static int gcd(int a,int b)
    {
        while(b!=0)
        {
            int ans = a%b;
            a = b;
            if(ans!=0)
            {
                b = ans;
            }
            else
            {
                return a;
            }
        }
        return -1;
    }
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext())
        {
            String[] lines = scan.nextLine().split(" ");
            int a = Integer.parseInt(lines[0]);
            int b = Integer.parseInt(lines[1]);
            System.out.println(gcd(a,b));
        }
        return 0;
    }
    public static void main(String[] args)
    {
        run(args);
    }
} Main
import java.util.Scanner;

/**
 * Created by ??\??? on 2016/12/2.
 */
public class Main {
    static int gcd(int a,int b)
    {
        while(b!=0)
        {
            int ans = a%b;
            a = b;
            if(ans!=0)
            {
                b = ans;
            }
            else
            {
                return a;
            }
        }
        return -1;
    }
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext())
        {
            String[] lines = scan.nextLine().split(" ");
            int a = Integer.parseInt(lines[0]);
            int b = Integer.parseInt(lines[1]);
            System.out.println(gcd(a,b));
        }
        return 0;
    }
    public static void main(String[] args)
    {
        run(args);
    }
}