N=int(input()) S=list(input()) T=list(input()) for i in range(N-2,-1,-1): if S[i]=="A" and S[i+1]=="B" and T[i+1]=="C": S[i]="B" S[i+1]="C" if S==T: print("Yes") else: print("No")