#include<stdio.h>
#include<stdio.h>
#include<stdlib.h>

int main(){
    char *a;
    char *b;
    char *c;
    a = (char *)malloc(10);
    b = (char *)malloc(10);
    c = (char *)malloc(10);

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

    int l,m,n;
    l = strlen(a);
    m = strlen(b);
    n = strlen(c);

    for(int i=0;i<l;i++){
        if(a[i]<'a' || a[i]>'z'){
                printf("No\n");
            return 0;
        }
    }

    for(int i=0;i<m;i++){
        if(b[i]<'a' || b[i]>'z'){
                printf("No\n");
            return 0;
        }
    }

    for(int i=0;i<n;i++){
        if(c[i]<'a' || c[i]>'z'){
                printf("No\n");
            return 0;
        }
    }


    if((a[l-1]==b[0]) || (b[m-1]==c[0])){
        if((a[l-1]==b[0]) && (b[m-1]!=c[0])){
            printf("No\n");
            printf("A and B form a word chain, but B and C do not.\n");
            return 0;
        }
       else if((a[l-1]!=b[0]) && (b[m-1]==c[0])){
            printf("No\n");
            printf("B and C form a word chain, but A and B do not.\n");
            return 0;
        }
       else if((a[l-1]==b[0]) && (b[m-1]==c[0])){
           printf("Yes\n");
           printf("They form a word chain.\n");
           return 0;
        }
    }

}
