for i in sorted(map(int,open('/dev/fd/0')),key=lambda i:[[99-i,i&-i][i>i&-i],i]):print i