from collections import defaultdict import sys input = sys.stdin.readline N = int(input()) S = input().strip() T = input().strip() D = defaultdict(int) for s, t in zip(S, T): D[s+t] += 1 if D["BA"]>0 or D["CA"]>0 or D["CB"]>0: print("No") exit() while D["AC"]>0 and D["BC"]>0: if D["AC"] > D["BC"]: D["AC"] = D["AC"]-D["BC"] else: D["AC"] = 0 while D["AB"]>0 and D["BC"]>0: if D["AB"] > D["BC"]: D["AB"] = D["AB"]-D["BC"] D["BC"] = 0 elif D["AB"] < D["BC"]: D["AB"] = 0 D["BC"] = D["BC"] - D["AB"] else: D["AB"] = 0 D["BC"] = 0 if D["AB"]==D["AC"]==D["BC"]==0: print("Yes") else: print("No")