#include using namespace std; using ll = long long; int N; string S, T; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> S >> T; bool f = true; for(int i = 0;i < N;i++){ f &= (S[i] <= T[i]); } for(int i = 0, a = 0;i < N;i++){ if(S[i] == T[i])continue; if(S[i] == 'A'){ if(T[i] == 'C'){ if(a-- == 0)f = false; } a += 1; } if(S[i] == 'B'){ if(a-- == 0)f = false; } if(i == N - 1 && a != 0)f = false; } cout << (f ? "Yes\n" : "No\n"); return 0; }