let rec euclid m n =
  if n = 0 then
    m
  else
    euclid n (m mod n);;

let () =
  let rec read () =
    try let (m,n) = Scanf.scanf "%d %d\n" (fun x y -> (x,y)) in
        Printf.printf "%d\n" (euclid m n);
        read ()
    with End_of_file -> ()
  in read ()
;;