#include #include #define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) using namespace std; using namespace atcoder; typedef long long ll; int main() { int n; string s, t; cin >> n >> s >> t; int ab = 0, bc = 0, ac = 0; rep(i, 0, n) { if (s[i] == t[i]) continue; if (s[i] == 'A' && t[i] == 'B') ab++; else if (s[i] == 'B' && t[i] == 'C') bc++; else if (s[i] == 'A' && t[i] == 'C') ac++; else { cout << "No" << endl; return 0; } } int ad = ab + bc + ac * 2; if (ad % 2) { cout << "No" << endl; return 0; } if (ab == bc && ac <= ab + bc) { cout << "Yes" << endl; } else { cout << "No" << endl; } }