#include<stdio.h>
main(){
  int n,m,i,r;
  while(scanf("%d %d",&n,&m)!=EOF){
    if(m<n){
      i=n;n=m;m=i;
    }
    while(1){
      if(n==0){
	printf("%d\n",m);
	break;
      }
      r=n;
      n=m%n;
      m=r;
    }
  }
  return 0;
}