X, Y = map(int, input().split())

ans: list[tuple[int, int]] = []

x, y = X, Y
ans.append((x, y))
while x > 1 or y > 1:
    if x > y:
        x = x - y
    else:
        y = y - x
    ans.append((x, y))

for x, y in reversed(ans):
    print(x, y)
