/*
 * Description: Compute the greatest common divisor of two numbers
 * Usage: gcd
 * Standard input: a b
 * Standard output: the greatest common divisor of numbers a and b.
 * Copyright: Daniel Tisza, 2010
 * All rights reserved
 */

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
  int tmp;
  int a;
  int b;

  if (argc != 1) /* validate argument count */
  {
    return 0;
  }

  while ( (tmp = scanf("%d %d", &a, &b)) != EOF) /* for all input lines */
  {
    if (tmp == 2) /* validate parsing */
    {
      if (a < b) /* invariant b < a */
      {
        tmp = a;
        a = b;
        b = tmp;
      }

      while (b) /* thm: gcd(a,b) = gcd(b, a mod b) */
      {
        tmp = a;
        a = b;
        b = tmp % b;
      }

      printf("%d", a);
    }
  }
}

