n = int(input()) s = input() t = input() AB, AC, BC = 0, 0, 0 ans = 1 for i in range(len(s)): if s[i] == t[i]: continue elif s[i] > t[i]: ans = 0 elif s[i] == "A" and t[i] == "B": AB += 1 elif s[i] == "A" and t[i] == "C": AC += 1 elif s[i] == "B" and t[i] == "C": BC += 1 if AB != BC: ans = 0 if AC > 0 and BC == 0: ans = 0 if ans: print("Yes") else: print("No")