#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int N; string S,T; int main() { cin >> N >> S >> T; int atob = 0, atoc = 0, btoc = 0; for(int i = 0; i < N; ++i) { if(S[i] == 'A' && T[i] == 'B') atob++; else if(S[i] == 'A' && T[i] == 'C') atoc++; else if(S[i] == 'B' && T[i] == 'C') btoc++; else if(S[i] == T[i]) continue; else { cout << "No" << endl; return 0; } } if(btoc > 0) atoc = 0; if(btoc == 0 && atob+atoc > 0) { cout << "No" << endl; return 0; } if(atob == btoc) cout << "Yes" << endl; else cout << "No" << endl; }