import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n = int(input()) s = input().rstrip() t = input().rstrip() all = 0 ok = 1 cnt = 0 ab = 0 bc = 0 ac = 0 for i in range(n): if (ord(s[i])) > ord(t[i]): ok = 0 if s[i] == "A" and t[i] == "C": ac += 1 if s[i] == "B" and t[i] == "C": bc += 1 if s[i] == "A" and t[i] == "B": ab += 1 if ok and ab == bc: if (ab == 0 and ac != 0): print('No') else: print('Yes') else: print('No')