#include<iostream>using namespace std;int main(void){ int b,c; while (cin >> b >> c) { while (1) { if (b > c) { b -= c; } else { c -= b; } if (b == c) { break; } } cout << b << endl; }}