import sys sys.setrecursionlimit(1000000) N, M = map(int, input().split()) def dfs(a, b): if b == 0: return print(a // b, end=" ") if b != 1: dfs(b, a % b) dfs(N, M)