def can_transform(S, T): S, T = list(S), list(T) for i in range(len(S)-1, -1, -1): if S[i] > T[i] or (S[i] == 'A' and T[i] == 'C'): return "No" for j in range(i, -1, -1): if S[j] == S[i]: S[j] = T[i] return "Yes" if S == T else "No" N = int(input().strip()) S = input().strip() T = input().strip() print(can_transform(S, T))