import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) #input = sys.stdin.readline n = int(input()) #alist = list(map(int,input().split())) #alist = [] s = input() #n,m = map(int,input().split()) #for i in range(n): # alist.append(list(map(int,input().split()))) t = input() ss = [] tt = [] ab = 0 ac = 0 bc = 0 for i in range(n): if s[i] == 'A' and t[i] == 'A': continue if s[i] == 'A' and t[i] == 'B': ab += 1 if s[i] == 'A' and t[i] == 'C': ac += 1 if s[i] == 'B' and t[i] == 'A': print('No') exit() if s[i] == 'B' and t[i] == 'B': continue if s[i] == 'B' and t[i] == 'C': bc += 1 if s[i] == 'C' and t[i] == 'A': print('No') exit() if s[i] == 'C' and t[i] == 'B': print('No') exit() if s[i] == 'C' and t[i] == 'C': continue if bc == 0: if ac == ab == 0: print('Yes') exit() print('No') exit() else: ac = 0 if ab == bc: print('Yes') else: print('No')