
#include <iostream>
#include <string.h>
using namespace std;
#define MAX 300

int myStrcmp(char s1[], char s2[]);
int myStrlen(char s[], int k);
void myStrcpy(char s[], int vt, char s1[], int k);
void mySubstr(char s[], int b, int count, char ss[]);
bool myStrcat(char s1[], char s2[]);
void StringReverse(char st[]);

int main()
{
	char s[MAX];
	fgets(s,300,stdin);
	if (myStrcmp(s, "") == 0)
		cout << "Chuoi rong." << endl;
	else
	{
		StringReverse(s);
		cout << s << endl;
	}
	return 0;
}

int myStrlen(char s[], int k)
{
    k = 0;
    while(s[k] != '\0' && s[k] != '\n')
        k++;
    return k;
}

int myStrcmp(char s1[], char s2[])
{
    if(s1[0] == '\n' || s1[0] == '\0')
        return 0;
    return 1;
}

void StringReverse(char st[])
{
    int len = myStrlen(st, len), temp;
    bool check = true;
    for(int i = 0; i < len; i++)
        if(st[i] == ' ')
        {
            check = false;
            break;
        }
    if(check)
    {
        for(int i = 0; i < len; i++)
            cout << st[i];
        st[0] = '\0';
        return;
    }
    for(temp = len - 1; temp >= 0; temp--)
    {
        if(st[temp] == ' ')
            break;
    }
    for(int i = temp + 1; i < len; i++)
        cout << st[i];
    cout << ' ';
    for(int i = temp; i >= 0; i--)
        if(st[i] == ' ')
            for(int j = i - 1; j >= 0; j--)
                if(st[j] == ' ')
                {
                    for(int k = j + 1; k < i; k++)
                    {
                        cout << st[k];
                    }
                    i = j;
                    cout << ' ';
                }
    temp = 0;
    while(st[temp] != ' ')
        cout << st[temp++];
    st[0] = '\0';
    return;
}