#include<iostream>
#include<vector>
#include<string>
using namespace std ;
int main()
{
    string s;
    getline(cin,s);
    for(int i=0;i<s.length();i++)
    {
        if(!((s[i]>='A'&& s[i]<='Z')||(s[i]>='a'&&s[i]<='z')||s[i]==''))
        {
            cout<<"Invalid input";
            return 0;
        }
    }
    vector<string>words;
    string temp="";
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='')
        {
            if(temp!="")
            {
                words.push_back(temp);
                temp="";
            }
        }
        else{
            temp+=s[i];
            
        }
    }
    if(temp!="")
    {
         words.push_back(temp);
    }
    int maxLen=0;
    for(int i=0;i<words.size();i++)
    {
        if(words[i].length()>maxLen)
        {
            maxLen=words[i].length();
        }
    }
    for(int i=0;i<maxLen;i++)
    {
        string line="";
        for(int j=0;j<words.size();j++)
        {
            if(i<words[j].length())
            {
                line+=words[j][i];
                
            }
            else
            {
                line+='';
            }
        }
        int end=line.length()-1;
        while(end>=0&&line[end]==' ')
        {
            end--;
        }
        cout<<line.substr(0,end+1);
        if(i !=maxLen-1)
        cout<<endl;
    }
    return 0;
        }
    }
        }
    }
}