#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; string s, t; cin >> n >> s >> t; bool ok = true; int ab = 0, ac = 0, bc = 0; rep(i, n) { if (s[i] == t[i]) continue; if (s[i] > t[i]) ok = false; if (s[i] == 'A' && t[i] == 'B') ab++; if (s[i] == 'A' && t[i] == 'C') ac++; if (s[i] == 'B' && t[i] == 'C') bc++; } if (ab != bc) ok = false; if (ac > 0 && bc == 0) ok = false; cout << (ok ? "Yes" : "No") << '\n'; return 0; }