#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
vector <int> a, b;
int element;
while (cin >> element) {
a.push_back(element);
}
bool getNegative = true;
for (int i = 0; i < a.size() - 1; i++) {
if (abs(a[i]) % 2 == 1 && a[i + 1] % 2 == 0) {
getNegative = false;
break;
}
}
if (getNegative) {
for (int i = a.size() - 1; i >= 0; i--) {
if (a[i] < 0) {
b.push_back(a[i]);
}
}
} else {
for (int i = a.size() - 1; i >= 0; i--) {
if (a[i] > 0) {
b.push_back(a[i]);
}
}
}
for (int i = 0; i < b.size(); i++) {
cout << b[i] << " ";
}
return 0;
}
I2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxhbGdvcml0aG0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKaW50IG1haW4oKSB7Cgl2ZWN0b3IgPGludD4gYSwgYjsKCWludCBlbGVtZW50OwoJd2hpbGUgKGNpbiA+PiBlbGVtZW50KSB7CgkJYS5wdXNoX2JhY2soZWxlbWVudCk7Cgl9Cglib29sIGdldE5lZ2F0aXZlID0gdHJ1ZTsKCWZvciAoaW50IGkgPSAwOyBpIDwgYS5zaXplKCkgLSAxOyBpKyspIHsKCQlpZiAoYWJzKGFbaV0pICUgMiA9PSAxICYmIGFbaSArIDFdICUgMiA9PSAwKSB7CgkJCWdldE5lZ2F0aXZlID0gZmFsc2U7CgkJCWJyZWFrOwoJCX0KCX0KCWlmIChnZXROZWdhdGl2ZSkgewoJCWZvciAoaW50IGkgPSBhLnNpemUoKSAtIDE7IGkgPj0gMDsgaS0tKSB7CgkJCWlmIChhW2ldIDwgMCkgewoJCQkJYi5wdXNoX2JhY2soYVtpXSk7CgkJCX0KCQl9Cgl9IGVsc2UgewoJCWZvciAoaW50IGkgPSBhLnNpemUoKSAtIDE7IGkgPj0gMDsgaS0tKSB7CgkJCWlmIChhW2ldID4gMCkgewoJCQkJYi5wdXNoX2JhY2soYVtpXSk7CgkJCX0KCQl9Cgl9CiAJZm9yIChpbnQgaSA9IDA7IGkgPCBiLnNpemUoKTsgaSsrKSB7CgkJY291dCA8PCBiW2ldIDw8ICIgIjsKCX0KCXJldHVybiAwOwp9