#include <stdio.h>
int main(){
  int a ,b ,x;
  while( scanf( "%d %d" ,&a ,&b ) != EOF ){
   do {
      x = a % b;
      a = b;
      b = x;
   } while( a % b != 0 );
    printf( "%d\n" ,x );
  }

  return 0;
}