import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ###################################################################### n = int(input()) s = input() t = input() x1, x2, x3 = 0,0,0 for i in range(len(s)): if s[i] == t[i]: continue elif s[i] > t[i]: No() exit() elif s[i] == "A" and t[i] == "B": x1 += 1 elif s[i] == "A" and t[i] == "C": x2 += 1 elif s[i] == "B" and t[i] == "C": x3 += 1 if x1 == x2 == x3 == 0: Yes() elif x1 == x3 and x1 > 0: Yes() else: No()