## https://yukicoder.me/problems/no/2629 MOD = 998244353 MAX = 10 ** 5 def main(): N = int(input()) S = input() T = input() a_to_b = 0 a_to_c = 0 b_to_c = 0 for i in range(N): s = S[i] t = T[i] if s > t: print("No") return elif s == t: continue elif s == "A" and t == "B": a_to_b += 1 elif s == "A" and t == "C": a_to_c += 1 elif s == "B" and t == "C": b_to_c += 1 if a_to_c == 0: if a_to_b == b_to_c: print("Yes") else: print("No") else: if b_to_c == 0: print("No") else: if a_to_b == b_to_c: print("Yes") else: print("No") if __name__ == "__main__": main()