#include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t N, i; string S, T; cin >> N >> S >> T; uint32_t count_AB = 0, count_AC = 0, count_BC = 0; for (i = 0; i != N; ++i) { if (S[i] > T[i]) { cout << "No\n"; return 0; } switch (S[i]) { case 'A': switch (T[i]) { case 'B': ++count_AB; break; case 'C': ++count_AC; break; } break; case 'B': if (T[i] == 'C') ++count_BC; break; } } if (count_AB >= 1 && count_BC >= 1) count_AC = 0; if (count_AC == 0 && count_AB == count_BC) cout << "Yes\n"; else cout << "No\n"; return 0; }