You are given three strings A, B and C. Check whether they form a word chain.

More formally, determine whether both of the following are true:

* The last character in A and the initial character in B are the same.
* The last character in B and the initial character in C are the same.



If both are true, print `YES`. Otherwise, print `NO`.

Constraints

* A, B and C are all composed of lowercase English letters (`a` - `z`).
* 1 ≤ |A|, |B|, |C| ≤ 10, where |A|, |B| and |C| are the lengths of A, B and C, respectively.

Input

Input is given from Standard Input in the following format:


A B C


Output

Print `YES` or `NO`.

Examples

Input

rng gorilla apple


Output

YES


Input

yakiniku unagi sushi


Output

NO


Input

a a a


Output

YES


Input

aaaaaaaaab aaaaaaaaaa aaaaaaaaab


Output

NO
/*
    なせば大抵なんとかなる！ 
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <windows.h>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")

#define amt(a) int a;scanf("%d",&a)
#define dlld(a,b) long long int a,b;scanf("%I64d %I64d",&a,&b)
#define scd(a) int a;scanf("%d",&a)
#define sclld(a) long long int a;scanf("%I64d",&a)
#define scs(a) char a[2000000];scanf("%s",a)
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define arr(a,b) int *a=(int *)malloc(n*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(n*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

typedef struct dlinkedlist
{
	int health;
	char name[50];
	struct dlinkedlist *next;
	struct dlinkedlist *prev;
}dll;

dll *head=NULL;
dll *tail=NULL;
int total=0;

void pushTail(int health,char *name)
{
	dll *node=(dll *)malloc(sizeof(dll));
	node->next=NULL;
	node->prev=NULL;
	node->health=health;
	strcpy(node->name,name);
	if(head==NULL && tail==NULL)
	{
		head=tail=node;
	}
	else
	{
		tail->next=node;
		node->prev=tail;
		tail=node;
	}
}

void pushHead(int health,char *name)
{
	dll *node =(dll *)malloc(sizeof(dll));
	node->next=NULL;
	node->prev=NULL;
	node->health=health;
	strcpy(node->name,name);
	if(head==NULL && tail==NULL)
	{
		head=tail=node;
	}
	else
	{
		head->prev=node;
		node->next=head;
		head=node;
	}
}

void pushPriority(int health,char *name)
{
	dll *node =(dll *)malloc(sizeof(dll));
	dll *pointer=head;
	node->next=NULL;
	node->prev=NULL;
	node->health=health;
	strcpy(node->name,name);
	if(head==NULL && tail==NULL)
	{
		pushTail(health,name);
	}
	else if(head->health>node->health)
	{
		pushHead(health,name);
	}
	else if(node->health>tail->health)
	{
		pushTail(health,name);
	}
	else
	{
		while(node->health>=pointer->health)
		{
			pointer=pointer->next;
		}
		node->next=pointer;
		node->prev=pointer->prev;
		pointer->prev->next=node;
		pointer->prev=node;
		
	}
}

void popst()
{
	if(head==tail)
	{
		free(head);
		head=tail=NULL;
	}
	else
	{
		tail=tail->prev;
		free(tail->next);
		tail->next=NULL;
	}
	total--;
}

void popq()
{
	if(head==tail)
	{
		free(head);
		head=tail=NULL;
	}
	else
	{
		head=head->next;
		free(head->prev);
		head->prev=NULL;
	}
	total--;
}

void popAll()
{
	dll *pointer=head;
	while(head!=NULL)
	{
		head=head->next;
		free(pointer);
		pointer=head;
		total=0;
		debug;
	}
}

void call()
{
	if(total<0)
	{
		printf("No Patient");
	}
	else
	{
		printf("Patient`s Name : %s\n",head->name);
		printf("Patient`s Health : %d\n",head->health);
		popq();
	}
	getchar();
}

void view()
{
	
	if(total<1)
	{
		printf("No Data");
	}
	else
	{
		dll *pointer=head;
		int num=1;
		while(pointer!=NULL)
		{
			printf("%-02d\n",num);
			printf("  Patient`s Name : %s\n",pointer->name);
			printf("  Patient`s Health : %d\n",pointer->health);
			pointer=pointer->next;
			num++; 
		}
	}
	getchar();
}

void add()
{
	int health;
	char name[50];
	printf("\n\n");
	do
	{
		printf("Input Patient`s Name [1-30] : ");
		scanf("%[^\n]",name);
		fflush(stdin);
	}while(strlen(name)<1 || strlen(name)>30);
	do
	{
		printf("Input Patient`s Health [1-100] : ");
		scanf("%d",&health);
		fflush(stdin);
	}while(health<1 || health>100);
	pushPriority(health,name);
	printf("\n--Patient Added--\n");
	total++;
	getchar();
}

void menu()
{
	system("cls");
	int mn;
	printf("Binus Hospital\n");
	printf("-----------------\n");
	printf("1. View Patient\n");
	printf("2. Add New Patient\n");
	printf("3. Call Patient\n");
	printf("4. Exit\n");
	do
	{
		printf("Choose : ");
		scanf("%d",&mn);
		fflush(stdin);
	}while(mn<1 || mn>4);
	
	if(mn==1)
	{
		view();
		menu();
	}
	else if(mn==2)
	{
		add();
		menu();
	}
	else if(mn==3)
	{
		call();
		menu();
	}
	else if(mn==4)
	{
		printf("Thank You");
		popAll();
		menu();
	}
}


int main()
{
 char a[5200],b[5200],c[5200];
scanf("%s %s %s" ,a,b,c);
int lena=strlen(a),lenb=strlen(b),lenc=strlen(c);
if(a[lena-1]==b[0] &&b[lenb-1]==c[0])
printf("YES\n");
else
printf("NO\n");
	return 0;
}
