# T=int(input()) # for _ in range(T): # x1,y1,x2,y2,X1,Y1,X2,Y2=map(int,input().split()) N=int(input()) S=input() T=input() if S==T: print('Yes') exit() x,y,z=0,0,0 for i in range(N): s,t=S[i],T[i] if s!=t: if s=='A' and t=='B': x+=1 elif s=='A' and t=='C': y+=1 elif s=='B' and t=='C': z+=1 else: print('No') exit() if x!=z: print('No') exit() if z>0: print('Yes') else: print('No')