Python
import sys
d = [i for i in sys.stdin] #непрерывный ввод с клавиатуры
w = [ ]
a = [ ]
b = [ ]
c = [ ]
x = [ ] # пять пустых списков
for i in range(len(d)):
if d[i] % 2 == 0 and i % 2 == 1:
a.append(d[i])
elif d[i] % 2 == 1 and i % 2 == 1:
b.append(d[i])
elif d[i] % 2 == 1 and i % 2 == 0:
c.append(d[i])
else:
x.append(d[i])
w += a[: : -1] + b[: : -1] + c + x
print(w)