import re
def find_number(string):
    numbers = re.findall(r'\d+', string)  # Tìm tất cả các chuỗi con gồm các chữ số
    if numbers:
        return numbers
    else:
        return None
def uc(x,y):
    while x != y:
        if x > y:
            x -= y
        else:
            y -= x
    return x

# Xâu ký tự đầu vào
with open('DIEMTHUONG.INP', 'r') as f:
    input_string = f.read()
    f.close()


t_number = find_number(input_string)
a = sorted(list(map(int,t_number)))
tienthuong = uc(a[0],a[1])
for i in range (2,len(a)):
    tienthuong = uc(tienthuong,a[i])
# In kết quả
with open('DIEMTHUONG.OUT', 'w') as f:
    f.write(str(tienthuong) +'\n')
    for i in a:
        f.write(str(i) + ' ')