#include <bits/stdc++.h>
using namespace std;
class Node{
	public:
	string data;
	Node* next;
	Node(const string& data){
		this->data=data;
		this->next=nullptr;
	}
};
class CLL{
	public:
	Node* head;
	Node* tail;
	CLL(){
		this->head=nullptr;
		this->tail=nullptr;
	}
	void insert(const string& s){
	
		Node* new_node=new Node(s);
		if(!head){
			head=new_node;
			tail=new_node;
			new_node->next=new_node;
		}else{
		tail->next=new_node;
		new_node->next=head;
		tail=new_node;
			
		}
	}
	
	bool display(){
		if(!head){return false;}
			cout<<"nayaya"<<endl;
		Node* temp;
		temp=head;
		do{
			cout<<temp->data;
			temp=temp->next;   //this points to next pointer
		}while(temp->next!=head);
		return true;
	}
	
};
int main() {
CLL ok;
string s;
while(getline(cin,s)){
	transform(s.begin(),s.end(),s.begin(),::tolower);
	if(s=="exit") break;
	ok.insert(s);
}
ok.display();
	return 0;
}