#include #include using namespace std; using mint = atcoder::modint998244353; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int n; string s, t; cin >> n >> s >> t; int ab = 0, ac = 0, bc = 0; for (int i = 0; i < n; i++) { if (s[i] == t[i]) { continue; } if (s[i] > t[i]) { cout << "No" << endl; return 0; } if (s[i] == 'A' && t[i] == 'B') { ab++; } else if (s[i] == 'A' && t[i] == 'C') { ac++; } else if (s[i] == 'B' && t[i] == 'C') { bc++; } } if ((ab != bc) || (ac > 0 && ab == 0)) { cout << "No" << endl; } else { cout << "Yes" << endl; } }