S1=input() S2=input() S3=input() temp=S2[len(S2)-1]+S2[0:len(S2)-1] if S1==temp and S3==temp: print("Yes") else: print("No")