#include <iostream>

using namespace std;
//欧几里得算法
int GCD(int a, int b) {
    if (a == 0) {
        return b;
    } else if (b == 0) {
        return a;
    } else {
        return GCD(b, a % b);
    }
}
int main() {
    int a, b;
    while (scanf("%d %d", &a, &b) != EOF) {
        int x = GCD(a, b);
        cout << x;
    }
}