def euclid(a, b)
  if a%b == 0 || b%a == 0
    return [a, b].min
  end
  a, b = b, a if a < b
  euclid(a - b*(a/b), b)
end

while nums = gets do
  a, b = nums.split.map(&:to_i)
  puts euclid(a, b)
end