#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(void) {
	int p, q;
	while((scanf("%d %d", &p, &q)) == 2) {
		if(q > p) swap(p, q);
		while(q != 0)
			swap(p %= q, q);
		printf("%d\n", p);
	}
	return 0;
}