#include void solve() { int n; std::cin >> n; std::string s, t; std::cin >> s >> t; std::vector atob, btoc; for (int i = 0; i < n; i++) { if (s[i] != t[i]) { if (s[i] == 'A') { atob.push_back(i); } else if (s[i] == 'B' && t[i] == 'C') { btoc.push_back(i); } else { std::cout << "No" << '\n'; return; } } } while (!atob.empty() && !btoc.empty()) { int lhs = atob.back(); atob.pop_back(); int rhs = btoc.back(); btoc.pop_back(); s[lhs] = 'B'; if (t[lhs] == 'C') btoc.push_back(lhs); s[rhs] = 'C'; } std::cout << (s == t ? "Yes" : "No") << '\n'; } int main() { std::cin.tie(0)->sync_with_stdio(0); std::cout << std::fixed << std::setprecision(16); int t = 1; while (t--) solve(); }