#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
        NSString *s = [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
        NSArray *l = [s componentsSeparatedByString:@" "];
        NSString *A = [l objectAtIndex:0];
        NSString *B = [l objectAtIndex:1];
        NSString *C = [l objectAtIndex:2];
        
        NSString *ab = [A substringWithRange:NSMakeRange([A length]-1,1)];
        NSString *ba = [B substringWithRange:NSMakeRange(0,1)];
        NSString *bb = [B substringWithRange:NSMakeRange([B length]-1,1)];
        NSString *ca = [C substringWithRange:NSMakeRange(0,1)];
        NSString *answer = ([ab isEqualToString:ba] && [bb isEqualToString:ca])?@"YES":@"NO";
        
        NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
        [fileHandle writeData:[answer dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle writeData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle closeFile];
    }
    return 0;
}
