gcd'::(Int,Int)->Int->Int
gcd' (a,b) 1 = 1
gcd' (a,b) n 
    | (a`mod`n==0)&&(b`mod`n==0) = n
    | otherwise                  = gcd' (a,b) (n-1)

solve::(Int,Int)->Int
solve (a,b) = gcd' (a,b) (min a b)

main = do
    ss <- getContents
    mapM_ print $ map solve $ map (\x->(\y->(y!!0,y!!1)) $ map (\y->read y::Int) $ words x)$ lines ss