stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include <cstring>

#include<stdio.h>

#include <cctype>



using namespace std;



char s1[11],s2[11],s3[11];

int a,b,c,j,k,loop,i,temp = 0;



int main()

{

    cin>>s1;

    cin>>s2;

    cin>>s3;



    a = strlen(s1);

    b = strlen(s2);

    c = strlen(s3);



    if(a>0 && a<=10 && b>0 && b<=10 && c>0 &&c <=10)

    {

            if(s1[a-1]==s2[0] && s2[b-1]==s3[0])

            {

                printf("YES\n");

            }

            else

            {

                printf("NO\n");

            }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.293282755081235x):
#include <stdio.h>

#include <string.h>



int main (){

    char a[12];

    char b[12];

    char c[12];

    

    scanf("%s %s %s", &a, &b, &c);

    int k = strlen (a); 

    int t = strlen (b); 

    int f = strlen (c);

    if (a[k-1] == b[0] && b[t-1] == c[0]) {

        printf("YES\n");

    } 

	else {

        printf("NO\n");

    }

    

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main()

{

    char a[11],b[11],c[11];

    char n,m,p,q;

    cin>>a>>b>>c;





    n=a[strlen(a)-1];

    m=b[0];

    p=b[strlen(b)-1];

    q=c[0];



    if(n==m && p==q)

    {

        cout<<"YES"<<endl;

    }

    else

    {



        cout<<"NO"<<endl;



    }







    return 0;





}

// Faster C++ solution for the same problem (measured speedup: 5.316350523239263x):
#include <stdio.h>

#include <string.h>



int main (){

    char a[12];

    char b[12];

    char c[12];

    

    scanf("%s %s %s", &a, &b, &c);

    int k = strlen (a); 

    int t = strlen (b); 

    int f = strlen (c);

    if (a[k-1] == b[0] && b[t-1] == c[0]) {

        printf("YES\n");

    } 

	else {

        printf("NO\n");

    }

    

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    string a,b,c;

    cin>>a>>b>>c;



    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])

        cout<<"YES";

    else

        cout<<"NO";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.342854624148682x):
#include <stdio.h>

#include <string.h>



int main (){

    char a[12];

    char b[12];

    char c[12];

    

    scanf("%s %s %s", &a, &b, &c);

    int k = strlen (a); 

    int t = strlen (b); 

    int f = strlen (c);

    if (a[k-1] == b[0] && b[t-1] == c[0]) {

        printf("YES\n");

    } 

	else {

        printf("NO\n");

    }

    

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int main()

{ 

      string c,d,e;

       

      cin>>c>>d>>e;

 

      

      

        int n = c.length(); 

    char g[n + 1]; 

    strcpy(g, c.c_str()); 

    

     int m = d.length(); 

    char h[m + 1]; 

    strcpy(h, d.c_str()); 

    

    

     int o = e.length(); 

    char k[o + 1]; 

    strcpy(k, e.c_str()); 



     if((g[n-1]==h[0])&&(h[m-1]==k[0]))

        cout<<"YES";



     else  cout<<"NO";

     

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.346224347266781x):
#include <stdio.h>

#include <string.h>



int main (){

    char a[12];

    char b[12];

    char c[12];

    

    scanf("%s %s %s", &a, &b, &c);

    int k = strlen (a); 

    int t = strlen (b); 

    int f = strlen (c);

    if (a[k-1] == b[0] && b[t-1] == c[0]) {

        printf("YES\n");

    } 

	else {

        printf("NO\n");

    }

    

    return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a,b,c;

   cin>>a>>b>>c;

   int len=a.size();

   int len2=b.size();

   int len3=c.size();

   if(a[len-1]==b[0] && b[len2-1]==c[0] )cout<<"YES\n";

   else cout<<"NO";



}










// Faster C++ solution for the same problem (measured speedup: 5.342067423264992x):
#include <stdio.h>

#include <string.h>



int main (){

    char a[12];

    char b[12];

    char c[12];

    

    scanf("%s %s %s", &a, &b, &c);

    int k = strlen (a); 

    int t = strlen (b); 

    int f = strlen (c);

    if (a[k-1] == b[0] && b[t-1] == c[0]) {

        printf("YES\n");

    } 

	else {

        printf("NO\n");

    }

    

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include <cstring>

#include<stdio.h>

#include <cctype>



using namespace std;



char s1[11],s2[11],s3[11];

int a,b,c,j,k,loop,i,temp = 0;



int main()

{

    cin>>s1;

    cin>>s2;

    cin>>s3;



    a = strlen(s1);

    b = strlen(s2);

    c = strlen(s3);



    if(a>0 && a<=10 && b>0 && b<=10 && c>0 &&c <=10)

    {

            if(s1[a-1]==s2[0] && s2[b-1]==s3[0])

            {

                printf("YES\n");

            }

            else

            {

                printf("NO\n");

            }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.312973969596665x):
#include <stdio.h>

#include <string.h>

int main(){

 char a[100],  b[100],  c[100];

 scanf("%s %s %s", &a, &b, &c);

 

 int akhirA= strlen(a)-1;

 int akhirB= strlen(b)-1;

 if(a[akhirA] == b[0] && b[akhirB] == c[0]){

  puts("YES");

 }

 else{

  puts("NO");

 }

 return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main()

{

    char a[11],b[11],c[11];

    char n,m,p,q;

    cin>>a>>b>>c;





    n=a[strlen(a)-1];

    m=b[0];

    p=b[strlen(b)-1];

    q=c[0];



    if(n==m && p==q)

    {

        cout<<"YES"<<endl;

    }

    else

    {



        cout<<"NO"<<endl;



    }







    return 0;





}

// Faster C++ solution for the same problem (measured speedup: 5.336127550735448x):
#include <stdio.h>

#include <string.h>

int main(){

 char a[100],  b[100],  c[100];

 scanf("%s %s %s", &a, &b, &c);

 

 int akhirA= strlen(a)-1;

 int akhirB= strlen(b)-1;

 if(a[akhirA] == b[0] && b[akhirB] == c[0]){

  puts("YES");

 }

 else{

  puts("NO");

 }

 return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    string a,b,c;

    cin>>a>>b>>c;



    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])

        cout<<"YES";

    else

        cout<<"NO";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.3627302479150245x):
#include <stdio.h>

#include <string.h>

int main(){

 char a[100],  b[100],  c[100];

 scanf("%s %s %s", &a, &b, &c);

 

 int akhirA= strlen(a)-1;

 int akhirB= strlen(b)-1;

 if(a[akhirA] == b[0] && b[akhirB] == c[0]){

  puts("YES");

 }

 else{

  puts("NO");

 }

 return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int main()

{ 

      string c,d,e;

       

      cin>>c>>d>>e;

 

      

      

        int n = c.length(); 

    char g[n + 1]; 

    strcpy(g, c.c_str()); 

    

     int m = d.length(); 

    char h[m + 1]; 

    strcpy(h, d.c_str()); 

    

    

     int o = e.length(); 

    char k[o + 1]; 

    strcpy(k, e.c_str()); 



     if((g[n-1]==h[0])&&(h[m-1]==k[0]))

        cout<<"YES";



     else  cout<<"NO";

     

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.366112506532142x):
#include <stdio.h>

#include <string.h>

int main(){

 char a[100],  b[100],  c[100];

 scanf("%s %s %s", &a, &b, &c);

 

 int akhirA= strlen(a)-1;

 int akhirB= strlen(b)-1;

 if(a[akhirA] == b[0] && b[akhirB] == c[0]){

  puts("YES");

 }

 else{

  puts("NO");

 }

 return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a,b,c;

   cin>>a>>b>>c;

   int len=a.size();

   int len2=b.size();

   int len3=c.size();

   if(a[len-1]==b[0] && b[len2-1]==c[0] )cout<<"YES\n";

   else cout<<"NO";



}










// Faster C++ solution for the same problem (measured speedup: 5.361940118613908x):
#include <stdio.h>

#include <string.h>

int main(){

 char a[100],  b[100],  c[100];

 scanf("%s %s %s", &a, &b, &c);

 

 int akhirA= strlen(a)-1;

 int akhirB= strlen(b)-1;

 if(a[akhirA] == b[0] && b[akhirB] == c[0]){

  puts("YES");

 }

 else{

  puts("NO");

 }

 return 0;

}
// Slower C++ solution:
#include<iostream>

#include <cstring>

#include<stdio.h>

#include <cctype>



using namespace std;



char s1[11],s2[11],s3[11];

int a,b,c,j,k,loop,i,temp = 0;



int main()

{

    cin>>s1;

    cin>>s2;

    cin>>s3;



    a = strlen(s1);

    b = strlen(s2);

    c = strlen(s3);



    if(a>0 && a<=10 && b>0 && b<=10 && c>0 &&c <=10)

    {

            if(s1[a-1]==s2[0] && s2[b-1]==s3[0])

            {

                printf("YES\n");

            }

            else

            {

                printf("NO\n");

            }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.296294584713108x):
#include <stdio.h>

#include <string.h>



int main(){

    

    char a[15], b[15], c[15];

    scanf("%s", a);

	scanf("%s", b);

	scanf("%s", c);

	

	int lena = strlen(a);

	int lenb = strlen(b);

	int lenc = strlen(c);

	

	if(a[lena-1] == b[0] && b[lenb-1] == c[0]){

		printf("YES\n");

	}

	else{

		printf("NO\n");

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main()

{

    char a[11],b[11],c[11];

    char n,m,p,q;

    cin>>a>>b>>c;





    n=a[strlen(a)-1];

    m=b[0];

    p=b[strlen(b)-1];

    q=c[0];



    if(n==m && p==q)

    {

        cout<<"YES"<<endl;

    }

    else

    {



        cout<<"NO"<<endl;



    }







    return 0;





}

// Faster C++ solution for the same problem (measured speedup: 5.3193754782209215x):
#include <stdio.h>

#include <string.h>



int main(){

    

    char a[15], b[15], c[15];

    scanf("%s", a);

	scanf("%s", b);

	scanf("%s", c);

	

	int lena = strlen(a);

	int lenb = strlen(b);

	int lenc = strlen(c);

	

	if(a[lena-1] == b[0] && b[lenb-1] == c[0]){

		printf("YES\n");

	}

	else{

		printf("NO\n");

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    string a,b,c;

    cin>>a>>b>>c;



    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])

        cout<<"YES";

    else

        cout<<"NO";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.345894659722136x):
#include <stdio.h>

#include <string.h>



int main(){

    

    char a[15], b[15], c[15];

    scanf("%s", a);

	scanf("%s", b);

	scanf("%s", c);

	

	int lena = strlen(a);

	int lenb = strlen(b);

	int lenc = strlen(c);

	

	if(a[lena-1] == b[0] && b[lenb-1] == c[0]){

		printf("YES\n");

	}

	else{

		printf("NO\n");

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int main()

{ 

      string c,d,e;

       

      cin>>c>>d>>e;

 

      

      

        int n = c.length(); 

    char g[n + 1]; 

    strcpy(g, c.c_str()); 

    

     int m = d.length(); 

    char h[m + 1]; 

    strcpy(h, d.c_str()); 

    

    

     int o = e.length(); 

    char k[o + 1]; 

    strcpy(k, e.c_str()); 



     if((g[n-1]==h[0])&&(h[m-1]==k[0]))

        cout<<"YES";



     else  cout<<"NO";

     

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.349266300181969x):
#include <stdio.h>

#include <string.h>



int main(){

    

    char a[15], b[15], c[15];

    scanf("%s", a);

	scanf("%s", b);

	scanf("%s", c);

	

	int lena = strlen(a);

	int lenb = strlen(b);

	int lenc = strlen(c);

	

	if(a[lena-1] == b[0] && b[lenb-1] == c[0]){

		printf("YES\n");

	}

	else{

		printf("NO\n");

	}

	

	return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a,b,c;

   cin>>a>>b>>c;

   int len=a.size();

   int len2=b.size();

   int len3=c.size();

   if(a[len-1]==b[0] && b[len2-1]==c[0] )cout<<"YES\n";

   else cout<<"NO";



}










// Faster C++ solution for the same problem (measured speedup: 5.34510701092832x):
#include <stdio.h>

#include <string.h>



int main(){

    

    char a[15], b[15], c[15];

    scanf("%s", a);

	scanf("%s", b);

	scanf("%s", c);

	

	int lena = strlen(a);

	int lenb = strlen(b);

	int lenc = strlen(c);

	

	if(a[lena-1] == b[0] && b[lenb-1] == c[0]){

		printf("YES\n");

	}

	else{

		printf("NO\n");

	}

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include <cstring>

#include<stdio.h>

#include <cctype>



using namespace std;



char s1[11],s2[11],s3[11];

int a,b,c,j,k,loop,i,temp = 0;



int main()

{

    cin>>s1;

    cin>>s2;

    cin>>s3;



    a = strlen(s1);

    b = strlen(s2);

    c = strlen(s3);



    if(a>0 && a<=10 && b>0 && b<=10 && c>0 &&c <=10)

    {

            if(s1[a-1]==s2[0] && s2[b-1]==s3[0])

            {

                printf("YES\n");

            }

            else

            {

                printf("NO\n");

            }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.300715099125092x):
#include <stdio.h>

#include <string.h>



int main(){

    char a[15], b[10], c[10];

    scanf("%s %s %s", a,b,c);

    int al = strlen(a), bl = strlen(b), cl = strlen(c);

    if (a[al-1] == b[0] && b[bl-1] == c[0]){

        printf("YES\n");

    }

    else{

        printf("NO\n");

    }

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main()

{

    char a[11],b[11],c[11];

    char n,m,p,q;

    cin>>a>>b>>c;





    n=a[strlen(a)-1];

    m=b[0];

    p=b[strlen(b)-1];

    q=c[0];



    if(n==m && p==q)

    {

        cout<<"YES"<<endl;

    }

    else

    {



        cout<<"NO"<<endl;



    }







    return 0;





}

// Faster C++ solution for the same problem (measured speedup: 5.323815256935667x):
#include <stdio.h>

#include <string.h>



int main(){

    char a[15], b[10], c[10];

    scanf("%s %s %s", a,b,c);

    int al = strlen(a), bl = strlen(b), cl = strlen(c);

    if (a[al-1] == b[0] && b[bl-1] == c[0]){

        printf("YES\n");

    }

    else{

        printf("NO\n");

    }

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    string a,b,c;

    cin>>a>>b>>c;



    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])

        cout<<"YES";

    else

        cout<<"NO";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.350356572482136x):
#include <stdio.h>

#include <string.h>



int main(){

    char a[15], b[10], c[10];

    scanf("%s %s %s", a,b,c);

    int al = strlen(a), bl = strlen(b), cl = strlen(c);

    if (a[al-1] == b[0] && b[bl-1] == c[0]){

        printf("YES\n");

    }

    else{

        printf("NO\n");

    }

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int main()

{ 

      string c,d,e;

       

      cin>>c>>d>>e;

 

      

      

        int n = c.length(); 

    char g[n + 1]; 

    strcpy(g, c.c_str()); 

    

     int m = d.length(); 

    char h[m + 1]; 

    strcpy(h, d.c_str()); 

    

    

     int o = e.length(); 

    char k[o + 1]; 

    strcpy(k, e.c_str()); 



     if((g[n-1]==h[0])&&(h[m-1]==k[0]))

        cout<<"YES";



     else  cout<<"NO";

     

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.3537310270575755x):
#include <stdio.h>

#include <string.h>



int main(){

    char a[15], b[10], c[10];

    scanf("%s %s %s", a,b,c);

    int al = strlen(a), bl = strlen(b), cl = strlen(c);

    if (a[al-1] == b[0] && b[bl-1] == c[0]){

        printf("YES\n");

    }

    else{

        printf("NO\n");

    }

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a,b,c;

   cin>>a>>b>>c;

   int len=a.size();

   int len2=b.size();

   int len3=c.size();

   if(a[len-1]==b[0] && b[len2-1]==c[0] )cout<<"YES\n";

   else cout<<"NO";



}










// Faster C++ solution for the same problem (measured speedup: 5.349568266282885x):
#include <stdio.h>

#include <string.h>



int main(){

    char a[15], b[10], c[10];

    scanf("%s %s %s", a,b,c);

    int al = strlen(a), bl = strlen(b), cl = strlen(c);

    if (a[al-1] == b[0] && b[bl-1] == c[0]){

        printf("YES\n");

    }

    else{

        printf("NO\n");

    }

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

int i,j,k,n,m,x,y,z,flag;

struct yea{

	int x,y;

	char num[20];

} a[10000];

char ch;

bool cmp(struct yea a,struct yea b)

{

	if (a.x<b.x) return true;

 	return false;

}





int main()

{

	

	while(1)

	{

		scanf("%d%d",&n,&m);

		if ((n==0)&&(m==0)) break;

		scanf("%c",&ch);

		for(i=0;i<n;i++)

		{

			scanf("%s%d%d",&a[i].num,&x,&y);

			a[i].x=y-x+1;

			a[i].y=y;

		}

		sort(a,a+n,cmp);

		for(i=0;i<m;i++)

		{

			scanf("%d",&x);

			flag=-1;

			for(j=0;j<n;j++)

			{

				if (a[j].x<=x && x<= a[j].y)

				{

					flag=j;

					break;

				}

				if (a[j].x>x) break;

			}

			if (flag==-1) printf("Unknown\n");

			else {

				printf("%s %d\n",a[flag].num,x-a[flag].x+1);

			}

		}

	}

	return 0;

	

}

// Faster C++ solution for the same problem (measured speedup: 5.054788214243704x):
#include <stdio.h>

#include <algorithm>

#define inf 1000000111

#define N 1005



using namespace std;



struct Calender

{

     int l, r;

     char st[22];

}cale[N];



int cmp(Calender x, Calender y)

{

     return x.l < y.l;

}



int main()

{

     int n, q, x;

     while(scanf("%d%d", &n, &q))

     {

          if(n == 0 && q == 0)

          {

               break ;

          }

          for(int i = 0; i < n; i++)

          {

               scanf("%s%d%d", cale[i].st, &x, &cale[i].r);

               cale[i].l = cale[i].r - x;

          }

          sort(cale, cale + n, cmp);

          cale[n].l = inf;



          while(q--)

          {

               scanf("%d", &x);

               for(int i = 0; i <= n; i++)

               {

                    if(cale[i].l >= x)

                    {

                         if(i > 0 && cale[i - 1].l < x && cale[i - 1].r >= x)

                         {

                              printf("%s %d\n", cale[i - 1].st, x - cale[i - 1].l);

                         }

                         else

                         {

                              printf("Unknown\n");

                         }

                         break ;

                    }

               }

          }

     }

     return 0;

}