main = interact $ ((flip (++)) "\n") . show . (\[a,b] -> mygcd a b) . take 2 . map read . words
mygcd 0 b = b
mygcd a 0 = a
mygcd a b = let a' = max a b
                b' = min a b
            in  mygcd b' (a' `mod` b')