n=int(input()) s=input() t=input() if s==t: exit(print("Yes")) flag=1 d=dict() for i in range(n): e=s[i]+t[i] if e not in d: d[e]=1 else: d[e]+=1 for e in ["BA","CA","CB"]: if e in d: flag=0 ab,bc,ca=0,0,0 if "AB" in d: ab=d["AB"] if "BC" in d: bc=d["BC"] if "AC" in d: ac=d["AC"] if bc==0:flag=0 if ab!=bc:flag=0 if flag==0: print("No") else: print("Yes")