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"

int _tmain(int argc, _TCHAR* argv[])
{
	//まずは変数を作って初期化
	char A[40];
	char Aend=' ',Bfirst=' ',Bend=' ',Cfirst=' ';
	int counter=0;
	for (int i=0; i<40; i++) {
		A[i]=' ';
	}

	//gets()で取得
	gets(A);

	for (int i=0 ; i<40; i++) {
		//空白がどこのものなのかをチェックする
		if (A[i]==' ')
			counter++;
		
		//一個目の空白をチェックしたら、Aの最後とBの最初がわかる
		if ((A[i]==' ')&&(counter==1)) {
			Aend=A[i-1];
			Bfirst=A[i+1]; 
		}
			
		//ニ個目の空白をチェックしたら、Bの最後とCの最初がわかる
		if ((A[i]==' ')&&(counter==2)) {
			Bend=A[i-1];
			Cfirst=A[i+1]; 
		}
	}

	/*
	//テスト
	printf("%s\n",A);
	printf("%c\n",Aend);
	printf("%c\n",Bfirst);
	printf("%c\n",Bend);
	printf("%c\n",Cfirst);
	*/

	//Aの最後とBの最初、Bの最後とCの最初が同じならしりとりが成立
	if ((Aend==Bfirst)&&(Bend==Cfirst))
		printf("YES");
	else
		printf("NO");

	return 0;
}

