#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 mid = n / 2;
for (int i = 0; i < n; ++i) {
b[i] = a[(i + mid) % n];
}
} else {
int mid = n / 2;
for (int i = 0; i < n; ++i) {
if (i == mid) {
b[i] = a[i];
} else {
b[i] = a[(i + mid + 1) % n];
}
}
}
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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBNQVhfU0laRSA9IDIwMDA7Cgpib29sIGlzTGV0dGVyKGNoYXIgYSkgewogICAgcmV0dXJuIChhID49ICdhJyAmJiBhIDw9ICd6JykgfHwgKGEgPj0gJ0EnICYmIGEgPD0gJ1onKTsKfQoKdm9pZCBjaGFuZ2VXb3JkKGNoYXIgYVtdKSB7CiAgICBpbnQgbiA9IHN0cmxlbihhKTsKICAgIGNoYXIgYltNQVhfU0laRV07CiAgICBpZiAobiAlIDIgPT0gMCkgewogICAgICAgIGludCBtaWQgPSBuIC8gMjsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkgewogICAgICAgICAgICBiW2ldID0gYVsoaSArIG1pZCkgJSBuXTsKICAgICAgICB9CiAgICB9IGVsc2UgewogICAgICAgIGludCBtaWQgPSBuIC8gMjsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkgewogICAgICAgICAgICBpZiAoaSA9PSBtaWQpIHsKICAgICAgICAgICAgICAgIGJbaV0gPSBhW2ldOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgYltpXSA9IGFbKGkgKyBtaWQgKyAxKSAlIG5dOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgYltuXSA9ICdcMCc7IC8vIFRlcm1pbmF0b3IgZGUgyJlpcgogICAgc3RyY3B5KGEsIGIpOwp9Cgp2b2lkIG1ha2VJbnZlcnNSb3coY2hhciBhW10pIHsKICAgIGludCBuID0gc3RybGVuKGEpOwogICAgaW50IGogPSAwOwogICAgY2hhciB3b3JkW01BWF9TSVpFXTsKICAgIGJvb2wgaW5Xb3JkID0gZmFsc2U7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgICAgICBpZiAoaXNMZXR0ZXIoYVtpXSkpIHsKICAgICAgICAgICAgaWYgKCFpbldvcmQpIHsKICAgICAgICAgICAgICAgIGogPSAwOwogICAgICAgICAgICAgICAgaW5Xb3JkID0gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICB3b3JkW2orK10gPSBhW2ldOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGlmIChpbldvcmQpIHsKICAgICAgICAgICAgICAgIHdvcmRbal0gPSAnXDAnOwogICAgICAgICAgICAgICAgY2hhbmdlV29yZCh3b3JkKTsKICAgICAgICAgICAgICAgIGNvdXQgPDwgd29yZDsKICAgICAgICAgICAgICAgIGluV29yZCA9IGZhbHNlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvdXQgPDwgYVtpXTsKICAgICAgICB9CiAgICB9CiAgICAKICAgIGlmIChpbldvcmQpIHsKICAgICAgICB3b3JkW2pdID0gJ1wwJzsKICAgICAgICBjaGFuZ2VXb3JkKHdvcmQpOwogICAgICAgIGNvdXQgPDwgd29yZDsKICAgIH0KfQoKaW50IG1haW4oKSB7CiAgICBjaGFyIHJvd1tNQVhfU0laRV07CiAgICB3aGlsZSAoY2luLmdldGxpbmUocm93LCBNQVhfU0laRSkpIHsKICAgICAgICBtYWtlSW52ZXJzUm93KHJvdyk7CiAgICAgICAgY291dCA8PCBlbmRsOyAvLyBBZGF1Z8SDIG8gbGluaWUgbm91xIMgZHVwxIMgZmllY2FyZSBsaW5pZSBwcm9jZXNhdMSDCiAgICB9CiAgICByZXR1cm4gMDsKfQ==