#include <iostream>
#include <cstring>
using namespace std;
const int MAX_SIZE = 2000;
bool isLetter(char a) {
return (a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z');
}
void changeWord(char a[]) {
int n = strlen(a);
char b[MAX_SIZE];
if (n % 2 == 0) {
int index = n / 2;
for (int i = 0; i < n; ++i) {
b[i] = a[index];
++index;
if (index == n) {
index = 0;
}
}
} else if (n % 2 != 0) {
int index = n / 2 + 1;
for (int i = 0; i < n; ++i) {
b[i] = a[index];
++index;
if (index == n) {
index = 0;
++i;
b[i] = a[n / 2];
}
}
}
b[n] = '\0'; // Terminator de șir
strcpy(a, b);
}
void makeInversRow(char a[]) {
int n = strlen(a);
int j = 0;
char word[MAX_SIZE];
bool inWord = false;
for (int i = 0; i < n; ++i) {
if (isLetter(a[i])) {
if (!inWord) {
j = 0;
inWord = true;
}
word[j++] = a[i];
} else {
if (inWord) {
word[j] = '\0';
changeWord(word);
cout << word;
inWord = false;
}
cout << a[i];
}
}
if (inWord) {
word[j] = '\0';
changeWord(word);
cout << word;
}
}
int main() {
char row[MAX_SIZE];
while (cin.getline(row, MAX_SIZE)) {
makeInversRow(row);
cout << endl; // Adaugă o linie nouă după fiecare linie procesată
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBNQVhfU0laRSA9IDIwMDA7Cgpib29sIGlzTGV0dGVyKGNoYXIgYSkgewogICAgcmV0dXJuIChhID49ICdhJyAmJiBhIDw9ICd6JykgfHwgKGEgPj0gJ0EnICYmIGEgPD0gJ1onKTsKfQoKdm9pZCBjaGFuZ2VXb3JkKGNoYXIgYVtdKSB7CiAgICBpbnQgbiA9IHN0cmxlbihhKTsKICAgIGNoYXIgYltNQVhfU0laRV07CiAgICBpZiAobiAlIDIgPT0gMCkgewogICAgICAgIGludCBpbmRleCA9IG4gLyAyOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKSB7CiAgICAgICAgICAgIGJbaV0gPSBhW2luZGV4XTsKICAgICAgICAgICAgKytpbmRleDsKICAgICAgICAgICAgaWYgKGluZGV4ID09IG4pIHsKICAgICAgICAgICAgICAgIGluZGV4ID0gMDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0gZWxzZSBpZiAobiAlIDIgIT0gMCkgewogICAgICAgIGludCBpbmRleCA9IG4gLyAyICsgMTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkgewogICAgICAgICAgICBiW2ldID0gYVtpbmRleF07CiAgICAgICAgICAgICsraW5kZXg7CiAgICAgICAgICAgIGlmIChpbmRleCA9PSBuKSB7CiAgICAgICAgICAgICAgICBpbmRleCA9IDA7CiAgICAgICAgICAgICAgICArK2k7CiAgICAgICAgICAgICAgICBiW2ldID0gYVtuIC8gMl07CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBiW25dID0gJ1wwJzsgLy8gVGVybWluYXRvciBkZSDImWlyCiAgICBzdHJjcHkoYSwgYik7Cn0KCnZvaWQgbWFrZUludmVyc1JvdyhjaGFyIGFbXSkgewogICAgaW50IG4gPSBzdHJsZW4oYSk7CiAgICBpbnQgaiA9IDA7CiAgICBjaGFyIHdvcmRbTUFYX1NJWkVdOwogICAgYm9vbCBpbldvcmQgPSBmYWxzZTsKCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkgewogICAgICAgIGlmIChpc0xldHRlcihhW2ldKSkgewogICAgICAgICAgICBpZiAoIWluV29yZCkgewogICAgICAgICAgICAgICAgaiA9IDA7CiAgICAgICAgICAgICAgICBpbldvcmQgPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHdvcmRbaisrXSA9IGFbaV07CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgaWYgKGluV29yZCkgewogICAgICAgICAgICAgICAgd29yZFtqXSA9ICdcMCc7CiAgICAgICAgICAgICAgICBjaGFuZ2VXb3JkKHdvcmQpOwogICAgICAgICAgICAgICAgY291dCA8PCB3b3JkOwogICAgICAgICAgICAgICAgaW5Xb3JkID0gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY291dCA8PCBhW2ldOwogICAgICAgIH0KICAgIH0KICAgIAogICAgaWYgKGluV29yZCkgewogICAgICAgIHdvcmRbal0gPSAnXDAnOwogICAgICAgIGNoYW5nZVdvcmQod29yZCk7CiAgICAgICAgY291dCA8PCB3b3JkOwogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIGNoYXIgcm93W01BWF9TSVpFXTsKICAgIHdoaWxlIChjaW4uZ2V0bGluZShyb3csIE1BWF9TSVpFKSkgewogICAgICAgIG1ha2VJbnZlcnNSb3cocm93KTsKICAgICAgICBjb3V0IDw8IGVuZGw7IC8vIEFkYXVnxIMgbyBsaW5pZSBub3XEgyBkdXDEgyBmaWVjYXJlIGxpbmllIHByb2Nlc2F0xIMKICAgIH0KICAgIHJldHVybiAwOwp9