a = list(map(int, input().split())) b = [] for id, item in enumerate(a[:-1]): if a[id + 1] != 0: b += [item] b += [a[-1]] print(*b)